7

I have an observable IObservable<T> / ISubject<T> and want to return that by using SignalR. SignalR has the concept of async streams where you have to return an IAsyncEnumerable<T>.

How can I transform an IObservable<T> to an IAsyncEnumerable<T>?

Rookian
  • 19,841
  • 28
  • 110
  • 180

1 Answers1

17

There is a ToAsyncEnumerable extension method in the System.Linq.Async assembly, available as a NuGet package here.

public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(
    this IObservable<TSource> source);
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104