【问题标题】:Is it possible to transform an IObservable<T> to an IAsyncEnumerable<T>是否可以将 IObservable<T> 转换为 IAsyncEnumerable<T>
【发布时间】:2020-03-13 16:01:42
【问题描述】:

我有一个可观察的 IObservable&lt;T&gt; / ISubject&lt;T&gt; 并希望使用 SignalR 将其返回。 SignalR 具有异步流的概念,您必须在其中返回 IAsyncEnumerable&lt;T&gt;

如何将IObservable&lt;T&gt; 转换为IAsyncEnumerable&lt;T&gt;

【问题讨论】:

    标签: c# signalr system.reactive iasyncenumerable


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多