Eternity
The Tango Store library natively supports enabling persistence and can specify field persistence, which can be achieved without introducing or using other libraries.
KeyPoints
- Storage exception handling: We don't have a specific
sessionStorage's
exception handling (e.g. storage write failure) doestry/catch
to avoid browser storage limitations orJSON
Crashes caused by parsing errors enhance fault tolerance. - Field-level persistence support:
persistentFields
is a practical mechanism for persisting all fields globally or avoiding persistence for sensitive or unnecessary data. - Multiple storage support:
localStorage
and are available.sessionStorage
flexible options to meet different state persistence needs.
Case
1.Code format
const myStore = createTangoStore(
initialValue: {},
options: {
storageKey: '',
Eternity: Boolean,
Storage: ''
},
persistentFields: []
);
2.Demo

const myStore = createTangoStore(
{ user: 'John Doe', theme: 'dark' },
{ storageKey: 'my-store', Eternity: true, Storage: 'session'},
['theme']
);
Note: The initial value is user: 'John Doe', theme: 'dark'
, with persistence turned on Eternity: true
, persist keyname storageKey: 'my-store'
,Storage: 'session'
, specifies persistence with sessionStorage
, specifies theme
Fields can be persisted.
createTangoStore parameters