// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. using System.Reactive.Subjects; using System.Threading.Tasks; namespace System.Reactive.Linq { // REVIEW: Expose Publish using ConcurrentSimpleAsyncSubject underneath. partial class AsyncObservable { public static IConnectableAsyncObservable Publish(this IAsyncObservable source) { if (source == null) throw new ArgumentNullException(nameof(source)); return Multicast(source, new SequentialSimpleAsyncSubject()); } public static IAsyncObservable Publish(this IAsyncObservable source, Func, IAsyncObservable> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return Multicast(source, () => new SequentialSimpleAsyncSubject(), selector); } public static IAsyncObservable Publish(this IAsyncObservable source, Func, Task>> selector) { if (source == null) throw new ArgumentNullException(nameof(source)); if (selector == null) throw new ArgumentNullException(nameof(selector)); return Multicast(source, () => Task.FromResult>(new SequentialSimpleAsyncSubject()), selector); } } }