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

            observer.OnSubscribe(parent);
            parent.Drain();
        }
Exemple #2
0
        protected override IDisposable SubscribeCore(IObserver <T> observer, IDisposable cancel)
        {
            observer = new RepeatObserver(observer, cancel);

            if (repeatCount == null)
            {
                return(scheduler.Schedule((Action self) =>
                {
                    observer.OnNext(value);
                    self();
                }));
            }
            else
            {
                return(scheduler.Schedule((Action self) =>
                {
                    if (currentCount > 0)
                    {
                        observer.OnNext(value);
                        currentCount--;
                    }

                    if (currentCount == 0)
                    {
                        observer.OnCompleted();
                        return;
                    }

                    self();
                }));
            }
        }
        public IDisposable Subscribe(IObserver <T> observer)
        {
            var parent = new RepeatObserver(observer, source, times);

            parent.Next();
            return(parent);
        }