1.0.0 • Published 8 years ago

redux-storage-engine-localstorage-map v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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