Skip to content

Enhancer for redux-localstorage that allows you to persist an immutable store

License

Notifications You must be signed in to change notification settings

jakelazaroff/redux-localstorage-immutable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-localstorage-immutable

npm npm

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!

About

Enhancer for redux-localstorage that allows you to persist an immutable store

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published