signalify-store
v1.0.7-experimental
Published
[![npm version](https://badge.fury.io/js/signalify-store.svg)](https://badge.fury.io/js/signalify-store)
Downloads
4
Readme
signals-store
Install
npm install signalify-store
Usage
import { createStore } from "signalify-store";
// create a store with a default value
const store = createStore({ count: 0 });
// get the value of the store
const count = store((state) => state.count);
// subscribe to the store
count.subscribe((count) => {
console.log("count", count);
// => 0
});
// update the store
count.value++;
// => count 1
Persist
const store = createStore(
{ count: 0 },
{
persist: {
name: "my-app",
storage: window.localStorage // or window.sessionStorage or window.caches or any other instance of Storage
},
},
);
Create a store with the given data and options.