It seems I need to do stuff on an ended stream, but not with an .onEnd()
. Let's say I've got a list of URLs which I need to fetch per XHR and inject into my application. After that's done, I'd like to do continue doing something that depends on that data, so I really can't do this in parallel. I'm trying something like this right now:
var data = Bacon.fromArray(myArray).flatMap(function(url) {
... fetch per XHR and return ...
});
data.onValue(function() { ... do something with data ... });
Bacon.onValues(
otherValue,
data,
function(value, data) {
// I need to check whether data stream ended
// if (data.isEnd()) obviously doesn't work
}
)
Not only does this not work, but it also doesn't feel right. How do I do this properly?
EDIT: I've managed to hack something working together: data.mapEnd('we are done').filter(function(v) { return v === "we are done"; })
, but I consider that a very dirty hack. Isn't there something more pure?