Data Store
The Data Store object provides access to the Digideck's Data Store behavior and state.
Methods
getAllData()
Description
- Gets all the data from the Data Store.
Return Value: Object
Code Example
this.allData = dataStore.getAllData();
getData(key)
Description
- Gets the data from the propery
keyin the Data Store.
Return Value: Any
Options:
key: StringIdentifier to get property data from Data Store.
Code Example
this.storePropertyData = dataStore.getData(key);
setData(key, value)
Description
- Sets the data for the store's property 'key' and alerts subscriptions after data is set.
Return Value: null
Options:
key: StringIdentifier to set store property data from Data Store.value: StringValue to set in the Data Store's property.
Code Example
dataStore.setData(key, value);
subscribe(key, callback, initialValue)
Description
- Subscribes to the Store's property
key, creates a store property to watch if it doesn't exist.
Return Value: Subscription Object
Options:
key: StringStore's property identifier key used to subscribe to Data Store property.callback: FunctionCallback invoked when subscription's property is updated.initialValue: ObjectInitial value for store property if property doesn't exist.
Code Example
this.subscription = dataStore.subscribe(key, callback, initialValue);
subscribeAll(callback)
Description
- Subscribes to the entire store. Callback invoked when updates are made to store.
Return Value: Subscription Object
Options:
callback: FunctionCallback invoked when Data Store is updated.
Code Example
this.subscription = dataStore.subscribeAll(callback);
clearAllData()
Description
- Clears all the data from the Data Store. And alerts subscriptions of updates.
Return Value: null
Code Example
dataStore.clearAllData();
clear(key)
Description
- Clears the data from the Data Store's property
key. And alerts subscriptions of the update.
Return Value: null
Code Example
dataStore.clear(key);