Package Exports
- redux-persistence-engine-localstorage
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-persistence-engine-localstorage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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)