예제 #1
0
        public IDisposable Subscribe(IObserver <T> observer)
        {
            if (maxConcurrency == int.MaxValue)
            {
                var srcs = sources;
                var n    = sources.Length;

                var parent = new MergeAllCoordinator(observer, n, delayErrors);

                if (n != 0)
                {
                    parent.Subscribe(srcs, n);
                }
                else
                {
                    parent.Drain();
                }

                return(parent);
            }
            else
            {
                var parent = new MergeLimitedCoordinator(observer, sources, delayErrors, maxConcurrency);
                parent.Drain();
                return(parent);
            }
        }
        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 IDisposable Subscribe(IObserver <T> observer)
        {
            var en = default(IEnumerator <IMaybeSource <T> >);

            try
            {
                en = RequireNonNullRef(sources.GetEnumerator(), "The GetEnumerator returned a null IEnumerator");
            }
            catch (Exception ex)
            {
                observer.OnError(ex);
                return(DisposableHelper.EMPTY);
            }

            if (maxConcurrency == int.MaxValue)
            {
                var parent = new MergeAllCoordinator(observer, delayErrors);

                parent.Subscribe(en);

                return(parent);
            }
            else
            {
                var parent = new MergeLimitedCoordinator(observer, en, delayErrors, maxConcurrency);
                parent.Drain();
                return(parent);
            }
        }
 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();
     }
 }