Modules
module-localstorage
Local Storage module allows using the browser's localStorage as a persistence layer for effects and attributes.
Installation#
Install with npm in your application:
Command
$ npm install --save \ @eventvisor/sdk \ @eventvisor/module-localstorage
Setting up#
And then set it up when initializing the SDK:
import { createInstance } from "@eventvisor/sdk";import { createLocalStorageModule } from "@eventvisor/module-localstorage";const eventvisor = createInstance({ modules: [ createLocalStorageModule(), ]});
Usage example#
Persist#
In your effect definition:
effects/myEffect.yml
# ...persist: localstorage
Lookup#
As a lookup, you can use it to read a value from the storage layer:
# ...conditions: - lookup: localstorage.myKey operator: equals value: myValue
Additional options#
You can optionally pass a different name, along with a custom prefix for the keys:
const eventvisor = createInstance({ modules: [ createLocalStorageModule({ // both are optional name: "myStorageName", // `localstorage` by default prefix: "myPrefix", }), ],})