Rx framework — IObservable<T>.Retry

As Wes Dyer put very ele­gant­ly:

Retry is to Repeat as Catch is to Con­cat

Ok ok, I know that’s not an exact quote, but I’m sure this is what he intend­ed to say in the first instance :-P

Any­how, the IObservable<T>.Retry method has all the same fea­tures of its Repeat sis­ter method, in that:

1. You can invoke it as exten­sion method:

var zs = xs.Retry(3);

or as sta­t­ic method:

var zs = Observable.Retry(xs, 3);

2. If you don’t give it a count, it’ll retry indef­i­nite­ly

3. xs.Retry(1) sub­scribes to xs only once, and xs.Retry(0) will not sub­scribe to xs at all.

Only this time, the rep­e­ti­tion of the observ­able col­lec­tion only hap­pens on excep­tion. So, if you take the illus­tra­tion from the pre­vi­ous post and swap the colours around and you will arrive at a pret­ty accu­rate illus­tra­tion of how Retry works: