public void Subscribe(ICompletableObserver observer)
        {
            if (maxConcurrency == int.MaxValue)
            {
                var parent = new MergeAllCoordinator(observer, delayErrors);
                observer.OnSubscribe(parent);
                parent.SubscribeAll(sources);
            }
            else
            {
                var en = default(IEnumerator <ICompletableSource>);
                try
                {
                    en = sources.GetEnumerator();
                }
                catch (Exception ex)
                {
                    DisposableHelper.Error(observer, ex);
                    return;
                }

                var parent = new MergeLimitedCoordinator(observer, en, delayErrors, maxConcurrency);
                observer.OnSubscribe(parent);
                parent.Drain();
            }
        }
 public void Subscribe(ICompletableObserver observer)
 {
     if (maxConcurrency == int.MaxValue)
     {
         var parent = new MergeAllCoordinator(observer, delayErrors);
         observer.OnSubscribe(parent);
         parent.SubscribeAll(sources);
     }
     else
     {
         var parent = new MergeLimitedCoordinator(observer, sources, delayErrors, maxConcurrency);
         observer.OnSubscribe(parent);
         parent.Drain();
     }
 }
        /// <summary>
        /// Subscribes the given completable observer to this subject
        /// and relays/replays the terminal events of the subject.
        /// </summary>
        /// <param name="observer">The completable observer that wants to listen to the terminal events.</param>
        public void Subscribe(ICompletableObserver observer)
        {
            var inner = new InnerDisposable(observer, this);

            observer.OnSubscribe(inner);

            if (Add(inner))
            {
                if (inner.IsDisposed())
                {
                    Remove(inner);
                }
            }
            else
            {
                if (!inner.IsDisposed())
                {
                    var ex = Volatile.Read(ref error);
                    if (ex == ExceptionHelper.TERMINATED)
                    {
                        observer.OnCompleted();
                    }
                    else
                    {
                        observer.OnError(ex);
                    }
                }
            }
        }
예제 #4
0
        public void Subscribe(ICompletableObserver observer)
        {
            RequireNonNull(observer, nameof(observer));

            var errorSignals = new UnicastSubject <Exception>();
            var redo         = default(IObservable <U>);

            try
            {
                redo = RequireNonNullRef(handler(errorSignals), "The handler returned a null IObservable");
            }
            catch (Exception ex)
            {
                DisposableHelper.Error(observer, ex);
                return;
            }

            var parent = new MainObserver(observer, source, new SerializedObserver <Exception>(errorSignals));

            observer.OnSubscribe(parent);

            var d = redo.Subscribe(parent.handlerObserver);

            parent.handlerObserver.OnSubscribe(d);

            parent.HandlerNext();
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new SwitchMapObserver(observer, mapper, delayErrors);
            observer.OnSubscribe(parent);

            parent.OnSubscribe(source.Subscribe(parent));
        }
            public void OnSubscribe(IDisposable d)
            {
                this.upstream = d;
                try
                {
                    onSubscribe?.Invoke(d);
                }
                catch (Exception ex)
                {
                    try
                    {
                        onDispose?.Invoke();
                    }
                    catch (Exception exc)
                    {
                        ex = new AggregateException(ex, exc);
                    }

                    upstream.Dispose();
                    upstream = DisposableHelper.DISPOSED;

                    DisposableHelper.Error(downstream, ex);

                    Finally();
                    return;
                }
                downstream.OnSubscribe(this);
            }
예제 #7
0
        internal static void Subscribe(ICompletableObserver observer, ICompletableSource[] sources, int n)
        {
            if (n == 0)
            {
                DisposableHelper.Complete(observer);
                return;
            }
            if (n == 1)
            {
                sources[0].Subscribe(observer);
                return;
            }

            var parent = new AmbDisposable(observer, n);

            observer.OnSubscribe(parent);

            var co = parent.observers;

            for (int i = 0; i < n; i++)
            {
                if (!parent.IsDisposed())
                {
                    sources[i].Subscribe(co[i]);
                }
            }
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new IgnoreAllElementsObserver(observer);

            observer.OnSubscribe(parent);
            parent.OnSubscribe(source.Subscribe(parent));
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new RepeatObserver(observer, source, predicate);

            observer.OnSubscribe(parent);
            parent.Drain();
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new DelaySubscriptionObserver(observer, source);

            observer.OnSubscribe(parent);
            other.Subscribe(parent);
        }
예제 #11
0
        public void Subscribe(ICompletableObserver observer)
        {
            var bd = new BooleanDisposable();

            observer.OnSubscribe(bd);

            if (bd.IsDisposed())
            {
                return;
            }

            try
            {
                action();
            }
            catch (Exception ex)
            {
                if (!bd.IsDisposed())
                {
                    observer.OnError(ex);
                }
                return;
            }

            if (!bd.IsDisposed())
            {
                observer.OnCompleted();
            }
        }
        public void Subscribe(ICompletableObserver observer)
        {
            if (maxConcurrency != int.MaxValue)
            {
                var parent = new FlatMapLimitedObserver(observer, mapper, delayErrors, maxConcurrency);
                observer.OnSubscribe(parent);

                parent.OnSubscribe(source.Subscribe(parent));
            }
            else
            {
                var parent = new FlatMapAllObserver(observer, mapper, delayErrors);
                observer.OnSubscribe(parent);

                parent.OnSubscribe(source.Subscribe(parent));
            }
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new TaskDisposable(observer);

            observer.OnSubscribe(parent);

            task.ContinueWith(TASK, parent);
        }
예제 #14
0
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new CompletableFlatMapSingleObserver <T>(observer, mapper);

            observer.OnSubscribe(parent);

            source.Subscribe(parent);
        }
예제 #15
0
        public void Subscribe(ICompletableObserver observer)
        {
            var sad = new SingleAssignmentDisposable();

            observer.OnSubscribe(sad);

            sad.Disposable = scheduler.Schedule(observer, time, COMPLETE);
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new TimeoutObserver(observer, fallback);

            observer.OnSubscribe(parent);
            parent.SetTask(scheduler.Schedule(parent, timeout, RUN));
            source.Subscribe(parent);
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new DelaySubscriptionObserver(observer, source);

            observer.OnSubscribe(parent);

            parent.SetTask(scheduler.Schedule(parent, delay, RUN));
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new TakeUntilObserver(observer);

            observer.OnSubscribe(parent);

            other.Subscribe(parent.other);
            source.Subscribe(parent);
        }
예제 #19
0
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new SubscribeOnObserver(observer, source);

            observer.OnSubscribe(parent);
            var d = scheduler.Schedule(parent, RUN);

            parent.SetTask(d);
        }
 public void OnSubscribe(IDisposable d)
 {
     if (DisposableHelper.SetOnce(ref upstream, d))
     {
         if (next != null)
         {
             downstream.OnSubscribe(this);
         }
     }
 }
예제 #21
0
 public void OnSubscribe(IDisposable d)
 {
     upstream = d;
     try
     {
         downstream.OnSubscribe(this);
     }
     catch (Exception)
     {
         d.Dispose();
         // TODO what should happen with these?
     }
 }
예제 #22
0
        public void Subscribe(ICompletableObserver observer)
        {
            var parent = new CreateDisposableEmitter(observer);

            observer.OnSubscribe(parent);
            try
            {
                onSubscribe(parent);
            }
            catch (Exception ex)
            {
                parent.OnError(ex);
            }
        }
        public void Subscribe(ICompletableObserver observer)
        {
            var inner = new InnerDisposable(observer, this);

            observer.OnSubscribe(inner);

            if (Add(inner))
            {
                if (inner.IsDisposed())
                {
                    Remove(inner);
                }
            }
            else
            {
                if (!inner.IsDisposed())
                {
                    var ex = Volatile.Read(ref error);
                    if (ex == ExceptionHelper.TERMINATED)
                    {
                        observer.OnCompleted();
                    }
                    else
                    {
                        observer.OnError(ex);
                    }
                }
                return;
            }

            var src = Volatile.Read(ref source);

            if (src != null)
            {
                src = Interlocked.Exchange(ref source, null);
                if (src != null)
                {
                    var a = cancel;
                    cancel = null;
                    a?.Invoke(this);

                    src.Subscribe(this);
                }
            }
        }
예제 #24
0
        public void Subscribe(ICompletableObserver observer)
        {
            var en = default(IEnumerator <ICompletableSource>);

            try
            {
                en = RequireNonNullRef(sources.GetEnumerator(), "The sources returned a null IEnumerator");
            }
            catch (Exception ex)
            {
                DisposableHelper.Error(observer, ex);
                return;
            }
            var parent = new ConcatDisposable(observer, en, delayErrors);

            observer.OnSubscribe(parent);
            parent.Drain();
        }
예제 #25
0
        public void Subscribe(ICompletableObserver observer)
        {
            var srcs = sources;
            var n    = srcs.Length;

            if (n == 0)
            {
                DisposableHelper.Complete(observer);
                return;
            }

            if (n == 1)
            {
                srcs[0].Subscribe(observer);
                return;
            }

            var parent = new ConcatDisposable(observer, srcs, delayErrors);

            observer.OnSubscribe(parent);
            parent.Drain();
        }
 internal static void Error(this ICompletableObserver observer, Exception error)
 {
     observer.OnSubscribe(EMPTY);
     observer.OnError(error);
 }
 public void OnSubscribe(IDisposable d)
 {
     upstream = d;
     downstream.OnSubscribe(this);
 }
 public void Subscribe(ICompletableObserver observer)
 {
     observer.OnSubscribe(DisposableHelper.EMPTY);
 }
 internal static void Complete(this ICompletableObserver observer)
 {
     observer.OnSubscribe(EMPTY);
     observer.OnCompleted();
 }