Plugin is used for storing state to external storages like localStorage . Due its async nature it supports also storages like IndexDB
localStorage
IndexDB
To do this you need to access store either from actions either injected to component and do following:
from actions
this.store.storage.save()
from component
this.store.select(['state-to-save-path']).storage.save()
save - saves state to storage.
PersistStateParams params can be passed.
PersistStateParams
Returns: Observable<PersistStateItem> with saved key and object
Observable<PersistStateItem>
load - loads and applies state from storage (state is deleted from storage afterwards at least keepEntry is passed as true).
keepEntry
true
removeItem - removes item from storage.
Returns Observable<string> with key that was removed.
Observable<string>
clear - clears all state items from storage (clears items that keys starts with state::).
state::
Returns Observable<string[]> with keys that was removed.
Observable<string[]>
Each method returns observable. Subscription is optional but once subscribed it gets notified once action is completed.
PersistStateParams:
custom key
custom storage config
custom deserialize function
custom serialize function
Last updated 7 years ago