question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

until/takeUntil with predicate function

See original GitHub issue

The 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:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
briancavaliercommented, Apr 27, 2017

Hey @OliverJAsh, we just released 1.3.0 with skipAfter. Check it out, and let us know if it works for you.

2reactions
briancavaliercommented, Apr 19, 2017

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 like until or since, 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found