A Cycle.js Driver for using localStorage and sessionStorage.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.scripts
docs
example
src
test
.babelrc
.editorconfig
.eslintrc
.gitattributes
.gitignore
.npmignore
.travis.yml
.zuul.yml
CONTRIBUTING.md
LICENSE
README.md
package.json
tsconfig.json

README.md

Cycle Storage Driver

A Cycle.js Driver for using localStorage and sessionStorage in the browser.

npm install --save @cycle/storage

Usage

You can read the API docs here.

Basics:

import Cycle from '@cycle/core';
import storageDriver from '@cycle/storage';

function main(responses) {
  // ...
}

const drivers = {
  storage: storageDriver
}

Cycle.run(main, drivers);

Simple and normal use case (JSBin demo):

function main({DOM, storage}) {
   const storageRequest$ = DOM.select('input')
    .events('keypress')
    .map(function(ev) {
      return {
        key: 'inputText',
        value: ev.target.value
      };
    });

  return {
    DOM: storage.local
    .getItem('inputText')
    .startWith('')
    .map((text) =>
      h('input', {
        type: 'text',
        value: text
      })
    ),
    storage: storageRequest$
  };
}

License

MIT