// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. using System.Runtime.CompilerServices; namespace System.Reactive { /// /// Extension of the interface compatible with async method return types. /// /// /// This class implements a "task-like" type that can be used as the return type of an asynchronous /// method in C# 7.0 and beyond. For example: /// /// async ITaskObservable<int> RxAsync() /// { /// var res = await Observable.Return(21).Delay(TimeSpan.FromSeconds(1)); /// return res * 2; /// } /// /// /// The type of the elements in the sequence. [AsyncMethodBuilder(typeof(TaskObservableMethodBuilder<>))] public interface ITaskObservable : IObservable { // NB: An interface type is preferred to enable the use of covariance. /// /// Gets an awaiter that can be used to await the eventual completion of the observable sequence. /// /// An awaiter that can be used to await the eventual completion of the observable sequence. ITaskObservableAwaiter GetAwaiter(); } /// /// Interface representing an awaiter for an . /// /// The type of the elements in the sequence. public interface ITaskObservableAwaiter : INotifyCompletion { /// /// Gets a Boolean indicating whether the observable sequence has completed. /// bool IsCompleted { get; } /// /// Gets the result produced by the observable sequence. /// /// The result produced by the observable sequence. T GetResult(); } }