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); } })); }
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(); })); }