baconjs / bacon.js

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

bus.end() doesn't work if bus has no subscribers #572

Closed Macil closed 9 years ago

Macil commented 9 years ago
$ node
> var Bacon = require('baconjs');
undefined
> var bus = new Bacon.Bus();
undefined
> bus.ended
false
> bus.end()
undefined
> bus.ended
true
> bus.log('b');
Bacon.Bus()
> bus.push(5);
b 5
[ '<more>' ]

I acknowledged this in #517 and wrote it off as a design quirk, but I feel differently now after noticing the misleading value of the ended property and having spent a day tracking down an issue that ultimately stemmed from this. (I've worked around it by adding bus.onValue(function(){}); right after creating the bus.)

raimohanska commented 9 years ago

Oh, that's interesting! Would you mind writing a failing test?

raimohanska commented 9 years ago

Wow, that was fast :)

raimohanska commented 9 years ago

Thanks @phadej for the fix. Released in 0.7.55. Sorry for delay.