I want to resume a sequence only under certain condition.
I have this Observable:
Observable
.Defer(() => Observable.FromAsync(SomeAsync))
.Retry();
The condition: The observable should retry only when it receives an CustomException
with a specific ResultCode
.
Then, I've thought about this:
Observable
.Defer(() => Observable.FromAsync(SomeAsync))
.Catch<T, CustomException>(exception => ShouldRetry(exception) ? ____ : Observable.Throw<T>(exception));
But, I don't know what to put in the ____ part, when the Observable should retry itself. It seems like the definition contains the concept to be defined, something recursive.
How do I make this conditional retry?