This might have been mentioned in the book but I don't remember it as a standalone suggestion...
I believe there is a simple reusable pattern to combine accum
, map
, and SwitchC
to update a Cell via a Stream. For example, given the following (typescript syntax where T is generic):
cFoo:Cell<T>
-
sBar:Stream<(data:T) => T>
We can get a cUpdatedFoo:Cell<T>
which is derived as the stream + old cell via:
const cUpdatedFoo =
Cell.switchC(
sBar.accum(cFoo, (fn, _c) => _c.map(fn))
)
Thoughts?