I'm trying to produce a stream similar to Bacon.fromPoll
for requestAnimationFrame
Why does the following code produce a "Maximum call stack exceeded" error?
function rafSequence() {
var raf = Bacon.fromCallback(function(callback) {
requestAnimationFrame(function() {
callback(Date.now());
});
});
return raf.merge(raf.flatMap(rafSequence));
}
rafSequence().log();
I thought merge()
would garbage collect when one of the 2 streams threw a Bacon.End
(the raf
in raf.merge(...)
. So why does it error?
UPDATE: I have been able to implement a working version as follows:
Bacon.repeat(() => Bacon.fromCallback(requestAnimationFrame));
I am still interested why merge()
isn't cleaning up.