Mozilla localForage driver for Cycle.js. Tested and ready.
Based on generic cycle-async-driver
API is absolutely compatible:
- https://github.com/mozilla/localForage
- https://github.com/localForage-extensions/localForage-setItems
- https://github.com/localForage-extensions/localForage-getItems
- https://github.com/localForage-extensions/localForage-removeItems
npm instlal cycle-forage
import {makeForageDriver} from 'cycle-forage'
import localForage from 'localforage'
let driver = makeForageDriver({
name: 'test', // default db name
storeName: 'testStore', // default store name
driver: localforage.WEBSQL // localForage.LOCALSTORAGE, localForage.INDEXEDDB
})
By default if driver not passed localForage uses indexeddb as storage engine.
{
// you may override default db and store for particular request
name: 'anotherDB',
storeName: 'anotherStore'
method: 'setItem', // explicit method
key: 'author',
value: 'Lewis Carol'
}
Or this way (params for methods with more then one param may come as array):
{
setItem: ['author', 'Lewis Carol'],
// setItem: {key: 'author', value: 'Lewis Carol'} is also supported
}
for methods with one arg, put no array
{
getItem: 'author',
}
setItems
supports key/value
array:
{
setItems: [
{key: 'author', value: 'Lewis Carol'},
{title: 'Through the Looking-Glass'}
],
}
or map:
{
setItems: {'author': 'Lewis Carol', title: 'Through the Looking-Glass'},
}
getItems
returns key/value
map
{
getItem: ['key'],
removeItem: ['key'],
setItem: ['key', 'value'],
keys: ['keys'],
length: [],
clear: [],
iterate: ['iterator'],
setItems: ['items'],
getItems: ['keys'],
removeItems: ['keys']
}
ISC