baconjs / bacon.js

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

`Bacon.noMore` doesn't work with `Bacon.once(1).merge(Bacon.interval(100, 2))` #523

Closed rpominov closed 9 years ago

rpominov commented 9 years ago

Not sure if I found a bug, or doing something wrong myself.

Following example doesn't work correctly. If ran in node it prints 1 but the node process doesn't terminates, which probably means that Bacon.interval(100, 2) still working.

Bacon = require('baconjs');

Bacon.once(1).merge(Bacon.interval(100, 2)).subscribe(function(event) {
  console.log(event);
  return Bacon.noMore;
});

If we take two events everything works just fine:

Bacon = require('baconjs');

var count = 0;
Bacon.once(1).merge(Bacon.interval(100, 2)).subscribe(function(event) {
  console.log(event);
  return count++ === 1 ? Bacon.noMore : Bacon.more;
});
raimohanska commented 9 years ago

Thanks @pozadi, a good find! Easily fixable too.

rpominov commented 9 years ago

Thanks :+1: