I have a method that returns an observable. This observable should (if evetything is working right) publish a value each second. What I would like to do is have it publish some custom alert value if a certain time has passed with no output.
private IObservable<string> GetStatus()
{
return statusProvider
.Subscribe(statusKey) //returns an IObservable<string>
.Select(st => st.ToUpper())
.DistinctUntilChanged()
.TakeUntil(disposed)
.Replay(1)
.RefCount();
}
Is there a simple way for me to modify the above so that if no status update has come in for 30 seconds, the statusProvider publishes "bad" and then if an update does come in after that, it get published as usual and the timer is restarted to 30 secs again?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…