I have a service that I would like to turn into a rx observable
The service has an interface of
IEnumerable<Price> FetchUpdatedPrices()
{
//do work to return changed data since last update
}
My idea was to use rx to allow a consumer to subscribe to updates. The implementation would poll the service every x seconds and call the observer.
I came up with the following
public IDisposable Subscribe(IObserver<IEnumerable<Price>> observer)
{
IObservable<IEnumerable<Price>> updatedPrices = Observable.Interval(new TimeSpan(0, 0, 1))
.Select(r => FetchUpdatedPrices());
return updatedPrices.Subscribe(observer);
}
The problem is I would like the observer to see an IObservable<Price> rather than an IObservable<IEnumerable<Price>>
Could anyone give this Rx noob any pointers on how to do this?
How about
SelectMany?