I have an outer
stream. I want to use this stream in two different ways.
First way is to just listen on values.
Second way is to build a new stream with flatMapConcat
.
But I can't do both at once. I think I have to fork or duplicate the stream.
I've tried adding a bus but it doesn't work.
var outer = Bacon.fromArray([1, 2, 3, 4, 5]);
// 1.way build a new stream
var combined = outer.flatMapConcat(function(v) {
return Bacon.sequentially(1000, ["a" + v, "b" + v]);
});
// 2. way use the plain stream
// outer.onValue(function(v) { console.log(v); });
// Tried to insert a bus
var forkBus = new Bacon.Bus();
forkBus.plug(outer);
forkBus.onValue(function(v) {
console.log('outer side' + v);
});
combined.take(3).log();
How can I fork/duplicate a stream so I can use it in two different ways?