JSPM

local-observable-store

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 34
  • Score
    100M100P100Q58380F
  • License MIT

An observable data-store that persists in local storage

Package Exports

  • local-observable-store

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (local-observable-store) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Local Observable Store

An observable data-store that persists in local storage. It's a subtype of observable-store, which means that it can be used just like the observable-store but also adds persistance in localStorage.

Installation

npm install local-observable-store

How to use

Require and initialize local-observable-store:

var LocalStore = require("local-observable-store"),
  localStore = new LocalStore();

Synchronize the local-observable-store with an already saved store in localStorage:

localStore.sync("persistedStore");

If there's anything currently in localStorage, it will be loaded in the store:

localStorage.setItem("persistedStore", JSON.stringify({ property: "value" }));

localStore = new LocalStore();
localStore.sync("peristedStore");

localStore.get("property"); // value

Then, everytime something changes in the local-observable-store, it's automatically persisted in localStorage.

localStore.set("newProperty", "hello!");

JSON.parse(localStorage.getItem("persistedStore")).newProperty; // "hello!";

CHANGELOG

0.0.3 - 13 SEP 2015

  • Update to latest observable-store
  • Update license field in package.json

LICENSE

MIT