Pause stream until another stream ends

已查看 13 次
跳至第一个未读帖子

m...@gmjs.ru

未读,
2016年2月20日 05:22:322016/2/20
收件人 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

未读,
2016年2月20日 06:18:502016/2/20
收件人 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.

回复全部
回复作者
转发
0 个新帖子