This is a library for reactive values.
The implementation is based on CustomEvent and EventTarget which are available in the Browser and recent server runtimes like Node.js 19 and Deno.
The API is heavily inspired by Recoil but this library is framework agnostic.
const counter$ = mutableValue(1)
console.log(counter$.value)
counter$.onChange((numberVal) => {
console.log(numberVal)
})const counter$ = mutableValue(1)
const doubleCounter$ = computedValue([counter$], (num) => num * 2)
console.log(doubleCounter$.value)
doubleCounter$.onChange((doubleCounterValue) => {
console.log(doubleCounterValue)
})const interval$ = automatedValue((next) => {
let val = 0
setInterval(() => {
next(val++)
}, 1000)
})
console.log(interval$.value)
interval$.onChange((intervalValue) => {
console.log(intervalValue)
})