コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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();
            }
        }
コード例 #3
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }

            var node = root;

            root = last = null;
            mode = (ReactivePropertyMode)IsDisposedFlagNumber;

            while (node != null)
            {
                node.OnCompleted();
                node = node.Next;
            }
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        /// <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;
        }