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'sexception handling (e.g. storage write failure) doestry/catchto avoid browser storage limitations orJSONCrashes caused by parsing errors enhance fault tolerance. - Field-level persistence support:
persistentFieldsis a practical mechanism for persisting all fields globally or avoiding persistence for sensitive or unnecessary data. - Multiple storage support:
localStorageand are available.sessionStorageflexible 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

