예제 #1
0
        public IDisposable Subscribe(UniRx.IObserver <T> observer)
        {
            if (lastException != null)
            {
                observer.OnError(lastException);
                return(Disposable.Empty);
            }
            if (isDisposed)
            {
                observer.OnCompleted();
                return(Disposable.Empty);
            }
            if (publisher == null)
            {
                publisher = new Subject <T>();
            }
            Subject <T> subject = publisher;

            if (subject != null)
            {
                IDisposable result = subject.Subscribe(observer);
                if (canPublishValueOnSubscribe)
                {
                    observer.OnNext(value);
                }
                return(result);
            }
            observer.OnCompleted();
            return(Disposable.Empty);
        }
예제 #2
0
        public IDisposable Subscribe(UniRx.IObserver <T> observer)
        {
            if (observer == null)
            {
                throw new ArgumentNullException("observer");
            }
            Exception ex    = null;
            T         value = default(T);
            bool      flag  = false;

            lock (observerLock)
            {
                ThrowIfDisposed();
                if (!isStopped)
                {
                    ListObserver <T> listObserver = outObserver as ListObserver <T>;
                    if (listObserver != null)
                    {
                        outObserver = listObserver.Add(observer);
                    }
                    else
                    {
                        UniRx.IObserver <T> observer2 = outObserver;
                        if (observer2 is EmptyObserver <T> )
                        {
                            outObserver = observer;
                        }
                        else
                        {
                            outObserver = new ListObserver <T>(new ImmutableList <IObserver <T> >(new IObserver <T>[2]
                            {
                                observer2,
                                observer
                            }));
                        }
                    }
                    return(new Subscription(this, observer));
                }
                ex    = lastError;
                value = lastValue;
                flag  = hasValue;
            }
            if (ex != null)
            {
                observer.OnError(ex);
            }
            else if (flag)
            {
                observer.OnNext(value);
                observer.OnCompleted();
            }
            else
            {
                observer.OnCompleted();
            }
            return(Disposable.Empty);
        }
예제 #3
0
 public override TResult Accept <TResult>(UniRx.IObserver <T, TResult> observer)
 {
     if (observer == null)
     {
         throw new ArgumentNullException("observer");
     }
     return(observer.OnCompleted());
 }
예제 #4
0
 public override void Accept(UniRx.IObserver <T> observer)
 {
     if (observer == null)
     {
         throw new ArgumentNullException("observer");
     }
     observer.OnCompleted();
 }
예제 #5
0
        public IDisposable Subscribe(UniRx.IObserver <T> observer)
        {
            if (observer == null)
            {
                throw new ArgumentNullException("observer");
            }
            Exception    ex           = null;
            Subscription subscription = null;

            lock (observerLock)
            {
                ThrowIfDisposed();
                if (!isStopped)
                {
                    ListObserver <T> listObserver = outObserver as ListObserver <T>;
                    if (listObserver != null)
                    {
                        outObserver = listObserver.Add(observer);
                    }
                    else
                    {
                        UniRx.IObserver <T> observer2 = outObserver;
                        if (observer2 is EmptyObserver <T> )
                        {
                            outObserver = observer;
                        }
                        else
                        {
                            outObserver = new ListObserver <T>(new ImmutableList <IObserver <T> >(new IObserver <T>[2]
                            {
                                observer2,
                                observer
                            }));
                        }
                    }
                    subscription = new Subscription(this, observer);
                }
                ex = lastError;
                Trim();
                foreach (TimeInterval <T> item in queue)
                {
                    observer.OnNext(item.Value);
                }
            }
            if (subscription != null)
            {
                return(subscription);
            }
            if (ex != null)
            {
                observer.OnError(ex);
            }
            else
            {
                observer.OnCompleted();
            }
            return(Disposable.Empty);
        }
예제 #6
0
 public IDisposable Subscribe(UniRx.IObserver <T> observer)
 {
     observer.OnCompleted();
     return(Disposable.Empty);
 }
예제 #7
0
 public IDisposable Subscribe(UniRx.IObserver <bool> observer)
 {
     observer.OnNext(value: true);
     observer.OnCompleted();
     return(Disposable.Empty);
 }
예제 #8
0
 public IDisposable Subscribe(UniRx.IObserver <Unit> observer)
 {
     observer.OnNext(Unit.Default);
     observer.OnCompleted();
     return(Disposable.Empty);
 }