public IDisposable Subscribe(IObserver <T> observer) { if (isDisposed) { observer.OnCompleted(); return(Disposable.Empty); } // raise latest value on subscribe observer.OnNext(value); // subscribe node, node as subscription. var next = new ObserverNode <T>(this, observer); if (root == null) { root = last = next; } else { last.Next = next; next.Previous = last; last = next; } return(next); }
protected virtual void Dispose(bool disposing) { if (isDisposed) { return; } sourceConnection.Dispose(); var node = root; root = last = null; isDisposed = true; while (node != null) { node.OnCompleted(); node = node.Next; } #if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6)) commonPromise?.SetCanceled(); commonPromise = null; if (removablePromises != null) { foreach (var item in removablePromises) { item.Value.SetCanceled(); } removablePromises = null; } #endif }
protected virtual void Dispose(bool disposing) { if (isDisposed) { return; } var node = root; root = last = null; isDisposed = true; while (node != null) { node.OnCompleted(); node = node.Next; } #if (CSHARP_7_OR_LATER) commonPromise?.SetCanceled(); commonPromise = null; if (removablePromises != null) { foreach (var item in removablePromises) { item.Value.SetCanceled(); } removablePromises = null; } #endif }
void IObserver<T>.OnError(Exception error) { lastException = error; // call source.OnError var node = root; while (node != null) { node.OnError(error); node = node.Next; } root = last = null; }
public IDisposable Subscribe(IObserver <T> observer) { if (lastException != null) { observer.OnError(lastException); return(Disposable.Empty); } if (isSourceCompleted) { if (canPublishValueOnSubscribe) { observer.OnNext(latestValue); observer.OnCompleted(); return(Disposable.Empty); } else { observer.OnCompleted(); return(Disposable.Empty); } } if (isDisposed) { observer.OnCompleted(); return(Disposable.Empty); } if (canPublishValueOnSubscribe) { observer.OnNext(latestValue); } // subscribe node, node as subscription. var next = new ObserverNode <T>(this, observer); if (root == null) { root = last = next; } else { last.Next = next; next.Previous = last; last = next; } return(next); }
void IObserverLinkedList<T>.UnsubscribeNode(ObserverNode<T> node) { if (node == root) { root = node.Next; } if (node == last) { last = node.Previous; } if (node.Previous != null) { node.Previous.Next = node.Next; } if (node.Next != null) { node.Next.Previous = node.Previous; } }
protected virtual void Dispose(bool disposing) { if (isDisposed) { return; } var node = root; root = last = null; isDisposed = true; while (node != null) { node.OnCompleted(); node = node.Next; } }
void IObserver <T> .OnCompleted() { isSourceCompleted = true; root = last = null; }