@supernaut/legend-state-persist-azure-functions-plugin
v1.1.0
Published
A plugin for persisting legend state in Azure Functions
Downloads
276
Maintainers
Readme
Legend State Azure Functions Persist Plugin
A plugin for persisting Legend State between invocations of Azure Functions.
Installation
npm i @supernaut/legend-state-persist-azure-functions-pluginpnpm add @supernaut/legend-state-persist-azure-functions-pluginUsage
import { observable, syncState, when } from '@legendapp/state';
import { syncObservable } from '@legendapp/state/sync';
import { observablePersistAzureStorage } from '@supernaut/legend-state-persist-azure-functions-plugin';
// Create your state
const store$ = observable({
key: 'value',
});
// Set up persistence with the plugin
syncObservable(state$, {
persist: {
name: 'store',
plugin: observablePersistAzureStorage({
connectionString: myConnectionString,
partitionKey: 'store',
tableName: 'persistedstatetable',
}),
},
});
// ...
// Wait for the persisted state to load
const status$ = syncState(state$);
await when(status$.isPersistLoaded);