// 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; using System.Threading.Tasks; namespace System { public static class AsyncObservableExtensions { public static Task SubscribeAsync(this IAsyncObservable source, Func onNextAsync, Func onErrorAsync, Func onCompletedAsync) { if (source == null) throw new ArgumentNullException(nameof(source)); if (onNextAsync == null) throw new ArgumentNullException(nameof(onNextAsync)); if (onErrorAsync == null) throw new ArgumentNullException(nameof(onErrorAsync)); if (onCompletedAsync == null) throw new ArgumentNullException(nameof(onCompletedAsync)); return source.SubscribeAsync(new AsyncObserver(onNextAsync, onErrorAsync, onCompletedAsync)); } } }