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); }
public IDisposable Subscribe(UniRx.IObserver <T> observer) { if (observer == null) { throw new ArgumentNullException("observer"); } Exception ex = null; T value = default(T); 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 })); } } value = lastValue; subscription = new Subscription(this, observer); } else { ex = lastError; } } if (subscription != null) { observer.OnNext(value); return(subscription); } if (ex != null) { observer.OnError(ex); } else { observer.OnCompleted(); } return(Disposable.Empty); }
public override TResult Accept <TResult>(UniRx.IObserver <T, TResult> observer) { if (observer == null) { throw new ArgumentNullException("observer"); } return(observer.OnNext(Value)); }
public override void Accept(UniRx.IObserver <T> observer) { if (observer == null) { throw new ArgumentNullException("observer"); } observer.OnNext(Value); }
public IDisposable Subscribe(UniRx.IObserver <bool> observer) { observer.OnNext(value: true); observer.OnCompleted(); return(Disposable.Empty); }
public IDisposable Subscribe(UniRx.IObserver <Unit> observer) { observer.OnNext(Unit.Default); observer.OnCompleted(); return(Disposable.Empty); }