Skip to content

Commit 4b06a2b

Browse files
committed
MC-19861: Update datastore docs
1 parent f6abd3d commit 4b06a2b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

docs/reference/data-store.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ Preview.contentType.dataStore;
1313

1414
## Events
1515

16-
The data store maintains its own event system. It does not use the global events system used by Page Builder. As a result, you need to create an instance of `dataStore` to observe events, as follows:
16+
The data store maintains its own event system. It does not use the global events system used by Page Builder. As a result, you need to create an instance of `dataStore` and subscribe to its data changes, as follows:
1717

1818
```js
1919
var dataStore = self.contentType.dataStore;
2020

21-
dataStore.events.on("state", function (state) {
22-
console.log(state);
21+
dataStore.subscribe(() => {
22+
// handler to update content type
2323
});
2424
```
2525

@@ -46,6 +46,12 @@ Set the entire state for the current content type.
4646
You can use the data store to modify your content type when its data changes. For example, the Page Builder native [Tabs content type](magento2-page-builder/app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/tabs/preview.ts) subscribes to the data store and makes updates to it when a tab-item changes, as follows:
4747

4848
```typescript
49+
...
50+
args.contentType.dataStore.subscribe(() => {
51+
this.updateTabNamesInDataStore();
52+
});
53+
...
54+
4955
/**
5056
* Update data store with active options
5157
*/

0 commit comments

Comments
 (0)