redux-localstorage-immutable
v1.0.4
Published
Enhancer for redux-localstorage that allows you to persist an immutable store
Downloads
124
Maintainers
Readme
redux-localstorage-immutable
Enhancer for redux-localstorage that allows you to persist an immutable store.
Installation
npm install --save redux-localstorage-immutable
Usage
import { serialize, deserialize } from 'redux-localstorage-immutable';
const reducers = compose(
mergePersistedState(deserialize)
)(reducers);
const storage = compose(
serialize
)(adapter(window.localStorage));
Methods
Note: I've documented the parameters here to explain what each method does, but in practice you can just pass them to the appropriate methods without worrying about it.
deserialize (state, payload)
Merges payload
into state
and returns the resulting Immutable. Used to take the JSON string from local storage and merge it into the store.
serialize (storage)
Adds a put
that converts the state to a JavaScript object and passes the storage object along. Used to prepare your Immutable for local storage. Probably should go before any other enhancers, unless they don't care about the state (like redux-localstorage-debounce) or they're expecting an Immutable rather than a plain JavaScript object.
Thanks
Cheers to redux-localstorage and redux-immutablejs!