Skip to main content

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 key in the Data Store.

Return Value: Any

Options:

  • key: String Identifier 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: String Identifier to set store property data from Data Store.
  • value: String Value 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: String Store's property identifier key used to subscribe to Data Store property.
  • callback: Function Callback invoked when subscription's property is updated.
  • initialValue: Object Initial 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: Function Callback 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);