I am trying to create a stream similar to Bacon.fromPollforrequestAnimationFrame
Why does the following code cause an error with exceeding the maximum amount of calls?
function rafSequence() {
var raf = Bacon.fromCallback(function(callback) {
requestAnimationFrame(function() {
callback(Date.now());
});
});
return raf.merge(raf.flatMap(rafSequence));
}
rafSequence().log();
I thought I merge()would collect garbage when one of the 2 threads threw Bacon.End( rafin raf.merge(...)). So why is this a mistake?
UPDATE: I was able to implement the working version as follows:
Bacon.repeat(() => Bacon.fromCallback(requestAnimationFrame));
I am still wondering why merge()it is not cleared.
source
share