2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-29 19:03:02 +02:00
|
|
|
title: Store
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
A **Store** object holds a simple key/value store with methods for storing and
|
|
|
|
retrieving data.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
## Signature
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
```js
|
|
|
|
Store Store.extend(Array methods=[])
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
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.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
## Example
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
```js
|
|
|
|
function myCustomMethod() {
|
|
|
|
// Do something clever
|
|
|
|
}
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
const store = new Store([
|
|
|
|
["path.to.the.method", myCustomMethod ]
|
|
|
|
])
|
|
|
|
```
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
With the configuration above, you can call `store.path.to.the.method()` and it
|
|
|
|
will run `myCustomMethod()`.
|
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
2022-12-09 07:34:44 -08:00
|
|
|
A Store object exposes the following methods and properties:
|
2022-09-29 23:03:28 +02:00
|
|
|
|
|
|
|
<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.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-12-09 07:34:44 -08:00
|
|
|
Click below to learn more about:
|
|
|
|
|
|
|
|
- [How Stores work](/guides/patterns/store)
|