Exemplo n.º 1
0
        public static ICompletable Merge(this ICompletable[] sources)
        {
            return(Create(cs =>
            {
                MergeCompletableSubscriber mcs = new MergeCompletableSubscriber(cs);
                mcs.SpWip(sources.Length);

                foreach (ICompletable c in sources)
                {
                    if (mcs.IsDisposed() || mcs.LvWip() <= 0)
                    {
                        break;
                    }

                    c.Subscribe(mcs);
                }
            }));
        }
Exemplo n.º 2
0
        public static ICompletable Merge(this IEnumerable <ICompletable> sources)
        {
            return(Create(cs =>
            {
                MergeCompletableSubscriber mcs = new MergeCompletableSubscriber(cs);
                mcs.SpWip(1);

                foreach (ICompletable c in sources)
                {
                    if (mcs.IsDisposed() || mcs.LvWip() <= 0)
                    {
                        break;
                    }

                    mcs.IncrementWip();
                    c.Subscribe(mcs);
                }

                mcs.OnComplete();
            }));
        }