I have looked at RxJS and Bacon.js. There was a particularly important feature I needed that they couldn’t provide. For merging streams, they wait for all sources to emit an event for them to emit the merged event. In Samsara when you write
new SizeNode({
size : ...
margins : ...
});
this is a “merged stream” from two streams: size and margins. Both of them don’t need to be changing at the same time. It may be that only one is changing, and so I needed to come up with a way to still fire a change event on the merged stream (SizeNode). This involves a batching strategy tied to the request animation frame. Unfortunately this is a break to the modularity of the code, because it couples the FRP stuff to the raf cycle. I haven’t yet figured a way around this though. Maybe someone here has some good ideas.
I haven’t yet experimented with web workers. I think it should be relatively straightforward, as there is a clear separation between the purely JS parts and the parts that touch the DOM. Though honestly the JS execution time is quite small. Unlike famous, where the render tree was constructed from scratch each frame, because of the stream nature of samsara, only the subtrees where a change has occurred needs to be recomputed. There is only one way I’ve thought of to make it faster (and indeed optimal), which involves some aggressive caching. But with this method you can actually say that if N objects on the screen are moving, at most N matrix multiplications are happening, which is pretty cool.