kltk-observable
v0.4.0
Published
a simple observable data
Downloads
7
Readme
kltk Observable
a simple observable data
Installtion
npm install kltk-observable
Usage
import with esm
import { observable } from 'kltk-observable';
create a observable
const initial = {}; const store = observable(initial);
subscribe/unsubscribe observable state changes
const listener = (state) => { console.log('store changed', state); }; const unsubscribe = store.subscribe(listener); setTimeout(() => { // unsubscribe with subscribe return unsubscribe(); // unsubscribe with store // store.unsubscribe(listener); });