I just found nanostores which has a lot in common with our store implementation.
One improvement is the ability to trigger a callback at the same time as watching...
In nanostores const store.subscribe(cb) passes the current state to cb while const store.listen(cb) just watches.
In our store, this could be achieved in a minor version (backward compatible) with a second boolean argument to watch, although this prevents potentially multiple watchers being passed as an argument, which is an alternative signature.
I just found nanostores which has a lot in common with our store implementation.
One improvement is the ability to trigger a callback at the same time as watching...
In nanostores
const store.subscribe(cb)
passes the current state tocb
whileconst store.listen(cb)
just watches.In our store, this could be achieved in a minor version (backward compatible) with a second boolean argument to watch, although this prevents potentially multiple watchers being passed as an argument, which is an alternative signature.