Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mathieudutour/redux-storage-engine-localforage
localForage engine for redux-storage
https://github.com/mathieudutour/redux-storage-engine-localforage
engine localforage redux redux-storage
Last synced: 12 days ago
JSON representation
localForage engine for redux-storage
- Host: GitHub
- URL: https://github.com/mathieudutour/redux-storage-engine-localforage
- Owner: mathieudutour
- License: mit
- Created: 2016-04-07T11:18:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-27T13:19:03.000Z (almost 7 years ago)
- Last Synced: 2024-10-17T16:13:53.669Z (22 days ago)
- Topics: engine, localforage, redux, redux-storage
- Language: JavaScript
- Size: 6.84 KB
- Stars: 10
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# redux-storage-engine-localforage
[![build](https://travis-ci.org/mathieudutour/redux-storage-engine-localforage.svg)](https://travis-ci.org/mathieudutour/redux-storage-engine-localforage)
[![dependencies](https://david-dm.org/mathieudutour/redux-storage-engine-localforage.svg)](https://david-dm.org/mathieudutour/redux-storage-engine-localforage)
[![devDependencies](https://david-dm.org/mathieudutour/redux-storage-engine-localforage/dev-status.svg)](https://david-dm.org/mathieudutour/redux-storage-engine-localforage#info=devDependencies)[![license](https://img.shields.io/npm/l/redux-storage-engine-localforage.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-engine-localforage)
[![npm version](https://img.shields.io/npm/v/redux-storage-engine-localforage.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-engine-localforage)
[![npm downloads](https://img.shields.io/npm/dm/redux-storage-engine-localforage.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-engine-localforage)[localforage][] based engine for [redux-storage][]
## Installation
```bash
npm install --save redux-storage-engine-localforage
```## Usage
Stores everything using localforage.
```js
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`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter) and/or a [`reviver`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Using_the_reviver_parameter).
```js
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
[localforage]: https://github.com/mozilla/localForage
[redux-storage]: https://github.com/michaelcontento/redux-storage
[redux-storage-engine-localforage]: https://github.com/mathieudutour/redux-storage-engine-localforage