just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo
.
import valoo from 'https://unpkg.com/valoo'
// create an observable value:
const num = valoo(42)
// subscribe to value changes:
const unsub = num( v => console.log(v) )
// unsubscribe that listener:
unsub()
// set the value, invoking any listeners:
num(43)
// get the current value:
num() // 43
The light version is smaller but doesn't support unsubscribing.
The idea here was first implemented in Mithril. I believe the subscription mechanism is new though.
Apache-2.0. Copyright 2018 Google LLC.