public IDisposable Subscribe(IObserver <T> observer) { if (IsDisposed) { observer.OnCompleted(); return(Disposable.Empty); } if (IsRaiseLatestValueOnSubscribe) { 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); }
/// <summary> /// Unsubscribe all subscription. /// </summary> public void Dispose() { if (IsDisposed) { return; } var node = _root; _root = _last = null; _mode = (ReactivePropertyMode)IsDisposedFlagNumber; while (node != null) { node.OnCompleted(); node = node.Next; } ValidationTrigger.Dispose(); SourceDisposable.Dispose(); ValidateNotifyErrorSubscription.Dispose(); if (ErrorsTrigger.IsValueCreated) { ErrorsTrigger.Value.OnCompleted(); ErrorsTrigger.Value.Dispose(); } }
public void Dispose() { if (IsDisposed) { return; } var node = root; root = last = null; mode = (ReactivePropertyMode)IsDisposedFlagNumber; while (node != null) { node.OnCompleted(); node = node.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; } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting /// unmanaged resources. /// </summary> public void Dispose() { if (IsDisposed) { return; } var node = _root; _root = _last = null; _mode = (ReactivePropertyMode)IsDisposedFlagNumber; while (node != null) { node.OnCompleted(); node = node.Next; } _sourceSubscription?.Dispose(); _sourceSubscription = null; }