Closed rpominov closed 9 years ago
Just to mention, I am using .awaiting
as a limit for filterBy
:
Kefir.fromEvents(..., 'click')
.map(stopPropagation)
.filterBy(outerClicks.awaiting(someProcessInProgress))
.map(extractPos)...
@shamansir I usually do the following in a situation like this:
const clicks = Kefir.fromEvents(..., 'click').map(stopPropagation)
outerClicks.flatMap(() => clicks.takeUntilBy(someProcessInProgress)).map(extractPos)...
In other words:
- foo.filterBy(bar.awaiting(baz))
+ bar.flatMap(() => foo.takeUntilBy(baz))
@shamansir Oh, and btw, your example may work differently after/if we fix https://github.com/rpominov/kefir/issues/167 (stopPropagation side effect will be called only when filterBy holds true. I.e. filterBy+awaiting will work exactly like flatMap+takeUntilBy work now.)
Got it, thanks! Seems I should update my code again :).
And yeah, looks like #167 is a right decision.
If you think of it,
a.awaiting(b)
is justKefir.merge([a.map(() => true), b.map(() => false)])
, so it's not a big deal to do ad-hoc. Also notice that it completely discards values froma
andb
replacing them with booleans, but often we need those values, for instance:Honestly I've never used .awaiting myself.
Migration
Before
After