baconjs / bacon.js

Functional reactive programming library for TypeScript and JavaScript
https://baconjs.github.io
MIT License
6.47k stars 330 forks source link

When a Bacon.fromArray stream is done .take(N) produces N x undefined events #724

Closed semmel closed 5 years ago

semmel commented 5 years ago

Using Bacon.version 2.0.9 on Node.js 8.14.0 multiple .take(N) on a Bacon.fromArray() stream which is already completed, produce N times undefined for the subscriber. Bacon.sequentially works fine:

var s1 = Bacon.fromArray([0, 1, 2, 3]);
s1.take(2).log(); // -> 0, 1, <end>
s1.take(2).log(); // -> 2, 3, <end>
s1.take(2).log(); // -> undefined, undefined, <end> BUT SHOULD BE JUST <end>
// btw.
s1.take(N).log() // -> N x undefined , <end>

// Bacon.sequentially works as I would expect:
var s2 = Bacon.sequentially(10, [0, 1, 2, 3]);
s2.take(2).log(); // -> 0, 1, <end>
s2.take(2).log(); // -> 2, 3, <end>
s2.take(2).log(); // -> <end>
raimohanska commented 5 years ago

Hmmm looks bad, must investigate. I'll try to get some time for this soon, but I have a very busy week going on. Would greatly appreciate if you had a gander yourself trying to point out the problem.

semmel commented 5 years ago

Would greatly appreciate if you had a gander yourself trying to point out the problem.

Busy here as well, but I'll do...

raimohanska commented 5 years ago

Fixed in 2.0.10. Thanks @semmel !