-
Notifications
You must be signed in to change notification settings - Fork 1
Data
Clemens edited this page Aug 8, 2024
·
1 revision
It is possible to store arbitrary JSON data in a webstrate and listen for changes in it.
To store an item:
webstrate.data.setItem("foo", {"bar": "baz"})
To read an item:
webstrate.data.getItem("foo")
To read all data:
webstrate.data.content
To delete an item:
webstrate.data.deleteItem("foo")
It is also possible to do make multiple changes to data in one go with the update method:
webstrate.data.update(data => {
data.foo = "bar";
data.baz = "qux";
})
The following events are triggered when data is updated:
-
dataUpdatedwhen data changes -
dataUpdatedWithPatchSethas a payload with a patch set of changed that has happened to the data
dataUpdated and dataUpdatedWithPatchSet will only trigger on remote changes, if you want to listen to all changes (including local) append * to the event: dataUpdated* and dataUpdatedWithPatchSet*.