Skip to main content

Module: DistributedStoreClient

The Distributed Store Client handles creating, retrieving, and destroying stores. Stores are used to save and retrieve data either locally or globally. This data is not persisted. You can add listeners at multiple levels (store or field), and get the updated data as it's updated in the store. Fields are stored within the store as key/value pair. For more information, see the Distributed Store tutorial.

Classes

Functions

createStore

createStore(params, cb?): StandardPromise<StoreModel>

Creates a store.

FSBL.Clients.DistributedStoreClient.createStore(
{
store: "store1",
global: false,
persist: false,
values: {},
},
function (error, storeObject) {},
);

Parameters

NameTypeDescription
paramsObject-
params.global?booleanWhether a store is accessible outside of the component it's created in.
params.persist?booleanWhether to persist the values of the store to storage. The store must be global to use this flag.
params.storestringThe name of the store.
params.values?anyStarting values for the store.
cb?StandardErrorCallback<StoreModel>Will return the store on success.

Returns

StandardPromise<StoreModel>

Callback will receive the store


getStore

getStore(params, cb?): StandardPromise<StoreModel>

Retrieve a store if it exists in the local scope, otherwise from the global scope.

FSBL.Clients.DistributedStoreClient.getStore(
{
store: "store1",
},
function (error, storeObject) {},
);

Parameters

NameTypeDescription
paramsObject
params.global?booleanGet the store only from the global scope.
params.storestringThe name of the store.
params.waitForPersistentStoreToLoad?booleanSet this to true if you know you are getting a reference to a persistent [global] store
cb?StandardErrorCallback<StoreModel>Will return the value if found.

Returns

StandardPromise<StoreModel>

Returns the store


removeStore

removeStore(params, cb?): StandardPromise<boolean>

Remove a store. If global is not set and a local store isn't found, Finsemble will remove the global store.

FSBL.Clients.DistributedStoreClient.removeStore(
{
store: "store1",
global: true,
},
function () {},
);

Parameters

NameTypeDescription
paramsObject-
params.global?booleanWhether the store you're trying to remove is a global store.
params.storestringThe name of the store.
cb?StandardErrorCallback<boolean>Callback to be invoked when the store is removed.

Returns

StandardPromise<boolean>