Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.x: Add the TakeUntil(Func<T, bool>) operator #612

Merged
merged 4 commits into from
Jun 19, 2018

Conversation

akarnokd
Copy link
Collaborator

Add the TakeUntil operator overload with a predicate that will complete the sequence after an item has been emitted and then the predicate returns true for it:

Observable.Range(1, 10)
   .TakeUntil(item => item == 5)
   .Subscribe(Console.WriteLine);

which prints 1 through 5 and completes.

There is a similar operator: TakeWhile which performs the check before the item is emitted.

This is one of the operators present in RxJava and mentioned in #489.

@danielcweber
Copy link
Collaborator

This is highly useful, we should just make sure the difference from TakeUntil(p) to TakeWhile(!p) is very clear.

@akarnokd
Copy link
Collaborator Author

Beyond the XML doc, I've tried to indicate with the stopPredicate naming that it is true that stops whereas in TakeWhile, false stops.

@danielcweber danielcweber merged commit ae8c989 into dotnet:master Jun 19, 2018
@akarnokd akarnokd deleted the TakeUntilPredicate branch June 21, 2018 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants