I've implemented a polling logic checking the status of a RESTful service returning the status of a backend job. I've run into the problem of shutting down the polling and solved it with an "unsubBus". I'm wondering if this could be solved in a better way.
var unsubBus = new Bacon.Bus();
// Poll job status code until it's successful
var succStream = Bacon.interval(pollInterval)
.takeUntil(unsubBus)
.flatMapLatest(function (v) { return this.checkStatus(jobId); })
.filter(function(v) { return v === true; });
// Unsubscribe and do something
succStream.onValue(function (_) { unsubBus.push(true); });
succStream.onValue(function (_) { DO-SOMETHING; });