Skip to main content

Module: StorageClient

The Storage Client handles saving and retrieving data for your smart desktop.

See the Storing Data tutorial for an overview of using the Storage Client.

Type Aliases

ComponentMutateParams

Ƭ ComponentMutateParams: Object

Type declaration

NameTypeDescription
field?stringField to save.
fields?{ field: string }[]Fields to save.
key?stringKey to store the data under.
stateVar?"componentState" | "windowData"Whether the data is componentState or windowData. Defaults to "windowData"
topic?stringTopic that the data is stored under.
value?anyValue to save.

Functions

clearCache

clearCache(cb?, params?): StandardPromise<void>

Clears a storage adapter of all data.

Parameters

NameTypeDescription
cb?StandardErrorCallback<void>The callback to be invoked after the method completes successfully.
params?Object
params.topicstringThe storage topic that the data is cleared under.

Returns

StandardPromise<void>


get

get<T>(params, cb?): Promise<T>

deprecated Use getStandardized() for a standardized Promise<{err, data}>

This function returns a Promise<T> and rejects on an error. This is maintained for backward compatibility.

Get a value from storage.

FSBL.Clients.StorageClient.get(
{ topic: "finsemble", key: "testKey" },
function (err, data) {
var myData = data;
},
);

Type parameters

NameType
Tany

Parameters

NameTypeDescription
paramsObject
params.keystringThe key to get from storage.
params.topicstringThe topic that the data is saved under.
cb?StandardErrorCallback<T>Callback to be called on success.

Returns

Promise<T>


getStandardized

getStandardized<T>(params, cb?): StandardPromise<T>

Get a value from storage.

FSBL.Clients.StorageClient.getStandardized(
{ topic: "finsemble", key: "testKey" },
function (err, data) {
let myData = data;
},
);
const { err, data } = await FSBL.Clients.StorageClient.getStandardized({
topic: "finsemble",
key: "testKey",
});

Type parameters

NameType
Tany

Parameters

NameTypeDescription
paramsObject
params.keystringThe key to get from storage.
params.topicstringThe topic that the data is saved under.
cb?StandardErrorCallback<T>Callback to be called on success.

Returns

StandardPromise<T>


keys

keys(params, cb?): StandardPromise<string[]>

Get all keys for the topic.

FSBL.Clients.StorageClient.keys(
{ topic: "finsemble", keyPrefix: "test" },
function (err, data) {
let myKeys = data;
},
);
const { err, data } = await FSBL.Clients.StorageClient.keys({
topic: "finsemble",
keyPrefix: "test",
});

Parameters

NameTypeDescription
paramsObject
params.keyPrefix?stringFilter all keys that don't start with this prefix.
params.topicstringTopic for the keys to return.
cb?StandardErrorCallback<string[]>Callback to be called on success.

Returns

StandardPromise<string[]>


remove

remove(params, cb?): StandardPromise<void>

Delete a value from storage.

FSBL.Clients.StorageClient.remove({ key: "testKey" });
await FSBL.Clients.StorageClient.remove({ key: "testKey" });

Parameters

NameTypeDescription
paramsObject
params.keystringThe key to get from storage.
params.topicstringThe topic that the data is saved under.
cb?StandardErrorCallback<void>Callback to be called on success.

Returns

StandardPromise<void>


save

save(params, cb?): StandardPromise<void>

Save a key value pair into storage.

FSBL.Clients.StorageClient.save({
topic: "finsemble",
key: "testKey",
value: "testValue",
});
FSBL.Clients.StorageClient.save(
{ topic: "finsemble", key: "testKey", value: "testValue" },
(err, data) => {},
);
const { err, data } = await FSBL.Clients.StorageClient.save({
topic: "finsemble",
key: "testKey",
value: "testValue",
});

Parameters

NameTypeDescription
paramsComponentMutateParams
cb?StandardErrorCallback<void>Callback to be called on success.

Returns

StandardPromise<void>


setUser

setUser(params, cb?): StandardPromise<void>

Define the user name for storage (i.e., each user has unique storage).

FSBL.Clients.StorageClient.setUser({ user: "JohnDeere" });

Parameters

NameTypeDescription
paramsObject
params.userstringA unique key to store user data under
cb?StandardErrorCallback<void>Callback to be called on success.

Returns

StandardPromise<void>