Mobx Persist
$ npm install mobx-persist --save
Usage
// create the statehydrate'some', someStore// post hydration.thenconsole.log'some hydrated'
without decorators
hydrate'some', state.thenconsole.log'some hydrated'
with initial state
hydrate'some', someStore, initialState.thenconsole.log'some hydrated'
re-hydration
result.thenconsole.log'some hydrated'setTimeout, 3000
API
persist(schema)(object)
- arguments
- schema string/object Describes the type of data you are planning to persist. Not needed for JS primitive types. Options:
'object' | 'list' | 'map'
or a structured schema object. - observable any The observable that you are persisting.
- schema string/object Describes the type of data you are planning to persist. Not needed for JS primitive types. Options:
- returns a persistence-enabled version of observable
create(config)
- arguments
- config object Describes the storage container you want your data to reside in.
- storage localForage/AsyncStorage/localStorage localForage-style storage API. localStorage for Web (default), AsyncStorage for React Native
- jsonify bool Enables serialization as JSON
- debounce number Debounce interval applied to storage calls (in miliseconds, default 0).
- config object Describes the storage container you want your data to reside in.
- returns
- hydrate function
hydrate(key, store)
- key string The key of your datastore that you want to hydrate from your persisted record.
- store object The store in which that key resides.
- returns IHydrateResult
- hydrate function
IHydrateResult
interface extends Promise
- methods
- rehydrate function
- returns IHydrateResult
- rehydrate function