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

7

我有一个可观察对象IObservable<T>/ ISubject<T>,想通过使用SignalR返回它。SignalR有异步流的概念,您必须返回一个IAsyncEnumerable<T>

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

1个回答

17

System.Linq.Async 程序集中有一个名为 ToAsyncEnumerable 的扩展方法,可通过此处的 NuGet 包进行获取。

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接