chore: Updating final Store docs for v3
This commit is contained in:
parent
3391859fb7
commit
098d23c3b7
7 changed files with 230 additions and 28 deletions
|
@ -2,26 +2,44 @@
|
|||
title: Store
|
||||
---
|
||||
|
||||
The **Store** object holds a simple key/value store with
|
||||
methods for storing and retrieving information.
|
||||
A single store per pattern is shared by all pattern parts.
|
||||
A **Store** object holds a simple key/value store with methods for storing and
|
||||
retrieving data.
|
||||
|
||||
## Signature
|
||||
|
||||
```js
|
||||
Store Store.extend(Array methods=[])
|
||||
```
|
||||
|
||||
The constructor takes a single argument, an Array of methods to add to the
|
||||
store. Each entry in the array should be an array itself holding a path in
|
||||
dot notation and a method. See below for an example.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
function myCustomMethod() {
|
||||
// Do something clever
|
||||
}
|
||||
|
||||
const store = new Store([
|
||||
["path.to.the.method", myCustomMethod ]
|
||||
])
|
||||
```
|
||||
|
||||
With the configuration above, you can call `store.path.to.the.method()` and it
|
||||
will run `myCustomMethod()`.
|
||||
|
||||
## Methods
|
||||
|
||||
A Store object exposes the following methods:
|
||||
|
||||
<ReadMore list />
|
||||
|
||||
## Notes
|
||||
|
||||
A store is typically used to share information between parts. For example
|
||||
the length of the neck opening in one part can be used to calculate the
|
||||
length for the collar in another part.
|
||||
|
||||
The `Store` object exposes the following methods:
|
||||
|
||||
<ReadMore list />
|
||||
|
||||
<Tip>
|
||||
|
||||
###### The store is available as shorthand
|
||||
|
||||
You can access the store instance from the [Part.shorthand](/reference/api/part/shorthand/) method;
|
||||
|
||||
```js
|
||||
let { store } = part.shorthand();
|
||||
```
|
||||
|
||||
</Tip>
|
||||
<Fixme compact>Include link to guide</Fixme>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue