是否可以将 IObservable<T> 转换为 IAsyncEnumerable<T>

Is it possible to transform an IObservable<T> to an IAsyncEnumerable<T>

我有一个可观察的 IObservable<T> / ISubject<T> 并且想 return 通过使用 SignalR。 SignalR 具有异步流的概念,您必须 return 一个 IAsyncEnumerable<T>.

如何将 IObservable<T> 转换为 IAsyncEnumerable<T>

System.Linq.Async 程序集中有一个 ToAsyncEnumerable 扩展方法,可作为 NuGet 包使用 here

public static IAsyncEnumerable<TSource> ToAsyncEnumerable<TSource>(
    this IObservable<TSource> source);