2.0.0 • Published 8 years ago

redux-storage-engine-localforage v2.0.0

Weekly downloads
447
License
MIT
Repository
github
Last release
8 years ago

redux-storage-engine-localforage

build dependencies devDependencies

license npm version npm downloads

localforage based engine for redux-storage

Installation

  npm install --save redux-storage-engine-localforage

Usage

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);

License

MIT