Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Observable TakeUntil with Multiple Conditions

What's the best way to add multiple conditions to TakeUntil? Is it just a matter of chaining TakeUntil() calls to each other?

IObservable<MyClass> propertyToObserve = ...
var observable = propertyToObserve
    .TakeUntil(SomeCondition)
    .TakeUntil(OtherCondition)
    .Subscribe(value => ...);
like image 206
Matt Avatar asked Aug 13 '26 15:08

Matt


1 Answers

That is a reasonable way to do it. Another way is to merge the conditions:

source.TakeUntil(condition1.Merge(condition2))
.Subscribe(...);
like image 57
Brandon Avatar answered Aug 15 '26 06:08

Brandon