Skip to content

mathieudutour/redux-storage-engine-localforage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

localForage engine for redux-storage

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published