1.0.0 • Published 5 years ago

redux-persistence-engine-localstorage v1.0.0

Weekly downloads
96
License
MIT
Repository
github
Last release
5 years ago

Installation

npm install --save redux-persistence-engine-localstorage

Usage

Stores everything inside window.localStorage.

import createEngine from 'redux-persistence-engine-localstorage'
const engine = createEngine('my-save-key')

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

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

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', replacer, reviver);

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

Warning: This library only works on browsers that support Promises (IE11 or better)

Warning: If the browser doest not support LocalStorage, that should be handled before passing the engine to redux-persistence (see test)