localforage based engine for redux-storage
npm install --save redux-storage-engine-localforage
Stores everything using localforage.
import createEngine from 'redux-storage-engine-localforage'
const optionalLocalForageConfig = {
driver : localforage.WEBSQL, // Force WebSQL
name : 'myApp',
version : 1.0,
size : 4980736, // Size of database, in bytes. WebSQL-only for now.
storeName : 'keyvaluepairs', // Should be alphanumeric, with underscores.
description : 'some description'
}
engine = createEngine('my-save-key', optionalLocalForageConfig);
You can customize the saving and loading process by providing a replacer
and/or a reviver
.
import createEngine from 'redux-storage-engine-localforage';
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', optionalLocalForageConfig, replacer, reviver);
MIT