cujojs / most

Ultra-high performance reactive programming
MIT License
3.49k stars 231 forks source link

Kefir style pool support #211

Closed jwthomp closed 8 years ago

jwthomp commented 8 years ago

Have you considered supporting a Kefir style pool within most? (https://rpominov.github.io/kefir/#pool) It allows you to create a stream that you can add and remove sources to.

From Kefir's API documentation:

Pool is like merge to which you can dynamically add and remove sources. When you create a new pool it has no sources. Then you can add observables to it using the plug method, and remove them using unplug. Pool never ends.

briancavalier commented 8 years ago

Hi @jwthomp. Instead of an imperative plug/unplug APIs for adding and removing streams from a pool or bus, most.js intentionally takes a declarative approach. The idea is to use higher-order streams to build self-reconfiguring stream networks declaratively. It can be a different way to think about things, but removes many of the potential mistakes that come along with trying to manage highly asynchronous systems imperatively.

Have you seen the drag-n-drop example? It "plugs" and "unplugs" mouse down, move, and up events using switch. It's basically a mini stateful network that reconfigures itself (using switch) in response to events using higher order streams.

There are plenty of interesting riffs on the dynamic reconfiguration theme to be had by using join, switch and chain (aka flatMap), especially when you also use since, until, and during to declare when the "plugged" streams should unplug themselves.

I'll close this, since we don't intend to add a bus/pool style API to most.js. But please do feel free to continue to discuss here.

jwthomp commented 8 years ago

Thank you Brian. I'm going to read through the drag-n-drop example and see how I might apply it to what I believe I would like to achieve (I'm also hopeful that I'll learn something in drag-n-drop that changes my worldview). I'll follow up here with how that goes and if I come up with anything specific (or just say, that was awesome I'm sorted!)

Thank you again and thank you for your work on most!

briancavalier commented 8 years ago

Great, and feel free to join us on gitter