2

I have this Observable:

var obs = Observable
                .Defer(() => Observable.FromAsync(asyncFunc))
                .Retry()

It works, but I would like know when the sequence retries, so I would like to invoke a Logger.Log("Retrying...") whenever this happens.

How could I do it?

SuperJMN
  • 13,110
  • 16
  • 86
  • 185

1 Answers1

1

I would simply put some bog standard logging operator around it.

This does more than what you want but "teach a man to fish" - https://github.com/LeeCampbell/RxCookbook/blob/master/Instrumentation/Logging.md

Observable.Create<Unit>(obs =>
{
    Console.WriteLine("Subscribing!!");
    return Observable.FromAsync(AsyncFunc).Subscribe(obs);
}).Retry();
Lee Campbell
  • 10,631
  • 1
  • 34
  • 29