If I understood correctly, you're looking for a combinator that ends a stream when a truthy value appears in another stream. You can use a.takeUntil(b.filter(Bacon._.id))
to end a stream when a truthy value appears on b
. If b
is a Property, the result will end immediately in case b
holds a truthy value at start.
You solution might look like this.
aAction = sourceA
.flatMap(function() {
return Bacon.repeatedly (200, [1,2,3])
.takeUntil(sourceB.filter(Bacon._.id))
})
This one will start a new stream for each element of sourceA
and terminate that when a truthy value appears sourceB
.
Or, you can a.takeWhile(b.not())
if b
is a Property. Ends immediately if Property has a truthy value to start with.
So, if sourceB
is a Property holding true/false and you want to be emitting values only when it holds false
, you can
aAction = sourceA
.flatMap(function() {
return Bacon.repeatedly (200, [1,2,3])
.takeWhile(sourceB.not())
})