public static IAsyncObservable <TResult> ToAsyncObservable <TResult>(this Task <TResult> task) { if (task == null) { throw new ArgumentNullException(nameof(task)); } return(AsyncObservable.Create <TResult>(observer => task.AcceptAsync(observer))); }
public static IAsyncObservable <Unit> ToAsyncObservable(this Task task, IAsyncScheduler scheduler) { if (task == null) { throw new ArgumentNullException(nameof(task)); } if (scheduler == null) { throw new ArgumentNullException(nameof(scheduler)); } return(AsyncObservable.Create <Unit>(observer => task.AcceptAsync(observer, scheduler))); }
/// <summary> /// Pulls the specified cancellation token. /// </summary> /// <returns></returns> public IAsyncObservable <TElement> PullAll() { var observable = AsyncObservable.Create <TElement>(obs => { while (!_items.IsEmpty) { var item = PullOne(); if (item == null) { break; } obs.OnNextAsync(item); } return(Task.FromResult(AsyncDisposable.Nop)); }); return(observable); }