system.reactive Wrapping an async method as an observable


Example

Given an async method like this:

Task<string> GetNameAsync(CancellationToken cancellationToken)

Wrap it as an IObservable<string> like this:

Observable.FromAsync(cancellationToken => GetNameAsync(cancellationToken))