Skip to content

Commit cb8531b

Browse files
committed
MC-15146: Unify DataStore get and update interface
- Update documentation
1 parent 7cd6958 commit cb8531b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/reference/data-store.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
# Data Store
22

33
## 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.
55

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.
77

88
## 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.
1011

1112
## API
1213
#### `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.
1415

1516
#### `getState(): object`
16-
Get the entire state object for the current instance.
17+
Get the entire state object for the current content type instance.
1718

1819
#### `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.
2021

2122
#### `setState(): void`
2223
Set the entire state for the current content type.
2324

2425
## 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.
2627

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.
2829

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.
3031
```js
3132
dataStore.events.on("state", function (state) {
3233
console.log(state);

0 commit comments

Comments
 (0)