Exemple #1
0
        public static AwaitableAsyncSubject <TSource> GetAwaiter <TSource>(this IObservable <TSource> source)
        {
            var s = new AwaitableAsyncSubject <TSource>();

            source.SubscribeSafe(s);
            return(s);
        }
Exemple #2
0
        public static AwaitableAsyncSubject <TSource> RunAsync <TSource>(this IConnectableObservable <TSource> source, CancellationToken cancellationToken)
        {
            var s = new AwaitableAsyncSubject <TSource>();

            var cancel = new Action(() => s.OnError(new OperationCanceledException()));

            if (cancellationToken.IsCancellationRequested)
            {
                cancel();
                return(s);
            }

            var d = new CompositeDisposable(source.SubscribeSafe(s), source.Connect());

            cancellationToken.Register(d.Dispose);
            cancellationToken.Register(cancel);

            return(s);
        }
Exemple #3
0
 public Subscription(AwaitableAsyncSubject <T> subject, IObserver <T> observer)
 {
     _subject  = subject;
     _observer = observer;
 }