redux-storage-engine-localstorage-map

Version storage with migration for redux-storage


Keywords
redux, redux-storage, redux-storage-engine
License
MIT
Install
npm install redux-storage-engine-localstorage-map@1.0.0

Documentation

redux-storage-engine-localstorage-map

build

window.localStorage based engine for redux-storage.

Installation

npm install --save redux-storage-engine-localstorage-map

Usage

Stores a subset of your state tree inside window.localStorage.

import createEngine from 'redux-storage-engine-localstorage-map';
const engine = createEngine({
  'my-save-key': ['reducer1', 'reducer2']
  'my-second-save-key': ['reducer3', 'reducer4']
});

You can customize the saving and loading process by providing a replacer and/or a reviver.

import createEngine from 'redux-storage-engine-localstorage-map';

function replacer (key, value) {
  if (typeof value === 'string') {
    return 'foo';
  }
  return value;
}

function reviver (key, value) {
  if (key === 'foo') {
    return 'bar';
  }
  return value;
});

const engine = createEngine({
  'my-save-key': ['reducer1', 'reducer2']
  'my-second-save-key': ['reducer3', 'reducer4']
}, replacer, reviver);

Warning: localStorage does not expose a async API and every save/load operation will block the JS thread!

License

MIT