redux-persistence-engine-localstorage
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

redux-persistence-engine-localstorage

LocalStorage engine for redux-persistence

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)

Package Sidebar

Install

npm i redux-persistence-engine-localstorage

Weekly Downloads

215

Version

1.0.0

License

MIT

Unpacked Size

5.71 kB

Total Files

7

Last publish

Collaborators

  • decentraland-bot