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
Name | Type | Description |
---|---|---|
params | Object | - |
params.global? | boolean | Whether a store is accessible outside of the component it's created in. |
params.persist? | boolean | Whether to persist the values of the store to storage. The store must be global to use this flag. |
params.store | string | The name of the store. |
params.values? | any | Starting values for the store. |
cb? | StandardErrorCallback <StoreModel > | Will return the store on success. |
Returns
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
Name | Type | Description |
---|---|---|
params | Object | |
params.global? | boolean | Get the store only from the global scope. |
params.store | string | The name of the store. |
params.waitForPersistentStoreToLoad? | boolean | Set 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
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
Name | Type | Description |
---|---|---|
params | Object | - |
params.global? | boolean | Whether the store you're trying to remove is a global store. |
params.store | string | The name of the store. |
cb? | StandardErrorCallback <boolean > | Callback to be invoked when the store is removed. |
Returns
StandardPromise
<boolean
>