leonoel / missionary

A functional effect and streaming system for Clojure/Script
Eclipse Public License 2.0
630 stars 26 forks source link

Multiplexing flows #20

Closed lgrapenthin closed 3 years ago

lgrapenthin commented 3 years ago

Considering that flows can spawn expensive processes like subscribing to external APIs, it would be useful to be able to multiplex a flow.

leonoel commented 3 years ago

What would it look like ?

lgrapenthin commented 3 years ago

Something like (m/mult f) produces a mult, and (m/tap m) returns a flow from the mult. f would be started only once for as long as there are parallel taps.

leonoel commented 3 years ago

reactor is supposed to cover this. Inside a reactor context (i.e in the boot code or in reaction to an event), you can assign an identity to a flow with stream! or signal! (resp. for discrete and continuous flows). These functions return another flow subscribing to this identity. stream! will collect the backpressure of its subscribers before propagating it upstream so it's very close to core.async's mult/tap.

It's currently super badly documented, but have a look at #11, and if you can provide a more precise use case I'm happy to help.

lgrapenthin commented 3 years ago

Alright, thanks. Thats very useful. Also the mbx->flow conversion part of the example was an eye-opener.