Pause stream until another stream ends

13 views
Skip to first unread message

m...@gmjs.ru

unread,
Feb 20, 2016, 5:22:32 AM2/20/16
to Bacon.js
Assume that I have a button, which produces EventStream of clicks. When it is clicked, I spawn another stream, which may work for some time. I need the button to stop sending stream events (discard them) until my spawned stream ends.
Is there built-in functions for stream to wait for another stream?

Juha Paananen

unread,
Feb 20, 2016, 6:18:50 AM2/20/16
to m...@gmjs.ru, Bacon.js
I suppose you’re doing something like

    var workerE = clickE.flatMap(spawnNewWorkerStream)

This will spawn a new worker for each click. You can simply change it to

    var workerE = clickE.flatMapFirst(spawnNewWorkerStream)


Btw, I think you’ll generally get a better response by using Stack Overflow instead of Groups :)

-juha-

On 20 Feb 2016, at 12:22 , m...@gmjs.ru wrote:

Assume that I have a button, which produces EventStream of clicks. When it is clicked, I spawn another stream, which may work for some time. I need the button to stop sending stream events (discard them) until my spawned stream ends.
Is there built-in functions for stream to wait for another stream?

--
You received this message because you are subscribed to the Google Groups "Bacon.js" group.
To post to this group, send email to bac...@googlegroups.com.
Visit this group at https://groups.google.com/group/baconjs.

Reply all
Reply to author
Forward
0 new messages