1.0.0 • Published 9 years ago
redux-storage-engine-localstorage-map v1.0.0
redux-storage-engine-localstorage-map
window.localStorage based engine for redux-storage.
Installation
npm install --save redux-storage-engine-localstorage-mapUsage
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
1.0.0
9 years ago