kefirjs / kefir

A Reactive Programming library for JavaScript
https://kefirjs.github.io/kefir/
MIT License
1.87k stars 97 forks source link

Only the first stream is created when trying to create multiple streams #205

Closed kevinbarabash closed 8 years ago

kevinbarabash commented 8 years ago
const streamA = Kefir.stream(emitter => this.emitterA = emitter);
const streamB = Kefir.stream(emitter => this.emitterB = emitter);

Only the this.emitterA gets set. I put a breakpoint inside both callbacks to Kefir.stream, but only the first gets called. My expectation is that both would get called.

rpominov commented 8 years ago

Do you subscribe to both streams? The callback that you're passing to Kefir.stream() is called when stream gets the first subscriber. With this code alone none will be called actually.

kevinbarabash commented 8 years ago

That was the problem. Thanks for the quick response. Also, kefir is awesome. I always wanted to use frp, but I couldn't justify the size of rxjs.