|
1 | 1 | # Data Store
|
2 | 2 |
|
3 | 3 | ## Summary
|
4 |
| -The purpose of the data store is to store all configured data associated with a content types instance. This data can be modified by a number of different interfaces including live edit and the UI component edit panel. |
| 4 | +The data store's purpose is to store all configured data associated with a content type's instance. You can modify this data in several ways, including through live edit on the Admin stage or from the content type's UI component form editor. |
5 | 5 |
|
6 |
| -The data store is accessed when generating the data sets to be applied within the preview and master templates before render. |
| 6 | +Page Builder accesses the data store when generating the data sets in the preview and master templates before render. |
7 | 7 |
|
8 | 8 | ## Access
|
9 |
| -The data store is available for access on the `ContentType` implementation via the key `dataStore`. If you're within a preview or master you'll need to first access the content type through the `contentType` property. |
| 9 | + |
| 10 | +The data store is available for access on the `ContentType` implementation via the key `dataStore`. If you're within a preview or master component, you must first access the content type through the `contentType` property. |
10 | 11 |
|
11 | 12 | ## API
|
12 | 13 | #### `get(key: string, defaultValue?: any): any`
|
13 |
| -Retrieve a single value from the content types data store based on it's key, optionally provide a default value if no data is present. |
| 14 | +Retrieve a single value from the content type's data store based on its key. You can provide an optional default value if no data is present. |
14 | 15 |
|
15 | 16 | #### `getState(): object`
|
16 |
| -Get the entire state object for the current instance. |
| 17 | +Get the entire state object for the current content type instance. |
17 | 18 |
|
18 | 19 | #### `set(key: string, value: any): void`
|
19 |
| -Set a single piece of data into the data store. |
| 20 | +Set a single piece of data into the content type's data store. |
20 | 21 |
|
21 | 22 | #### `setState(): void`
|
22 | 23 | Set the entire state for the current content type.
|
23 | 24 |
|
24 | 25 | ## Events
|
25 |
| -The data store maintains it's own events system and does not use the global events system that's otherwise used by Page Builder. |
| 26 | +The data store maintains its own events system and does not use the global events system that's otherwise used by Page Builder. |
26 | 27 |
|
27 |
| -Due to this you'll require an instance of `dataStore` to observe events. |
| 28 | +Because of this, you need to create an instance of `dataStore` to observe events. |
28 | 29 |
|
29 |
| -We fire a single event called `state`, this returns the entire state and is fired whenever the state is changed. |
| 30 | +Page Builder fires a single event called `state`, which returns the entire state of the data store. Page Builder fires this event whenever the state changes. |
30 | 31 | ```js
|
31 | 32 | dataStore.events.on("state", function (state) {
|
32 | 33 | console.log(state);
|
|
0 commit comments