

sessionStorage's exception handling (e.g. storage write failure) does try/catch to avoid browser storage limitations or JSON Crashes caused by parsing errors enhance fault tolerance.persistentFields is a practical mechanism for persisting all fields globally or avoiding persistence for sensitive or unnecessary data.localStorage and are available.sessionStorage flexible options to meet different state persistence needs.const myStore = createTangoStore(
initialValue: {},
options: {
storageKey: '',
Eternity: Boolean,
Storage: ''
},
persistentFields: []
);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.
Prop | Type | Accepted Values | Description | Default |
|---|---|---|---|---|
initialValue | Object | Object | The first parameter, the Initial State object, is the initial value of the user-defined TangoStore | {} |
options | Object | Object | The second parameter, persistence, is an object that contains optional settings | - |
storageKey | String | tango-store-state | The first of the second parameter is used to store the key name of the persisted data | - |
Eternity | Boolean | true|false | The second property in the second parameter, whether persistence is enabled | false |
Storage | String | local|session | The third property in the second parameter, select the storage method | local |
persistentFields | Array | []/undefined | The third parameter, field-level persistence, is an array of field names that specifies which fields need to be persisted. If not specified, all fields are persisted by default | - |