until/takeUntil with predicate function
See original GitHub issueThe until
/takeUntil
function accepts an input stream, however I was wondering if we could add support for a predicate function? This is different from takeWhile
because it is inclusive of the first item to return false
.
For inspiration, have a look at the API for RxJava which has similar options (stream or predicate) for its takeUntil
operator: http://reactivex.io/RxJava/javadoc/rx/Observable.html#takeUntil(rx.functions.Func1)
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Request for takeUntil with predicate function #2420 - GitHub
I've run into an issue several times where I'm usingtakeWhile but I also want to include the last element from the source observable...
Read more >Close subscription on condition with takeUntil() - Stack Overflow
takeWhile (predicate: function(value, index): boolean, inclusive?: boolean): Observable. Emit values until provided expression is false.
Read more >Take, TakeUntil, TakeWhile & TakeLast in Angular Observable
The takeUntil(notifier) keeps emitting the values until it is notified to stop. takeWhile(predicate) emits the value while values satisfy ...
Read more >TakeUntil operator - ReactiveX
It uses a predicate function that evaluates the items emitted by the source Observable, rather than a second Observable, to terminate the resulting...
Read more >takeWhile - Learn RxJS
signature: takeWhile(predicate: function(value, index): boolean, inclusive?: boolean): Observable. Emit values until provided expression is false.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @OliverJAsh, we just released 1.3.0 with skipAfter. Check it out, and let us know if it works for you.
I kinda like the name
skipAfter
. It reads fairly nicely in prose: “skip all the events after ‘Fred’”, and in code:events.skipAfter(x => x === 'Fred')
.Trying to think of a name using “take” that describes this operation, without using the word “until” is tricky!
I think
takeUntil
, or anything using “until” with a predicate could be confusing, because it doesn’t necessarily have a strong indication of whether it’s inclusive or exclusive (that concern is also expressed in the RxJava thread). “When” has a similar problem, imho. I think the word “after” has a more clear connotation. “After” has a time connotation, which could lead someone to believe it’s likeuntil
orsince
, but “while” has the same issue. Maybe then it’s helpful if we stick with “until” and “since” as time vocabulary, and “while” and “after” as predicate vocabulary?Other ideas?
cc @davidchase @TylorS