From a84e5e346094b92cac48f5b44acee667574ddef1 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 5 Nov 2018 11:03:02 -0600 Subject: [PATCH] SPARK-1805 Removing a synthetic disables the remove menu for the life of the window --- src/client/spark/core/Utility/KeyDrivenObservable.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/spark/core/Utility/KeyDrivenObservable.cs b/src/client/spark/core/Utility/KeyDrivenObservable.cs index 9e3b668ed..e0e3e27b8 100644 --- a/src/client/spark/core/Utility/KeyDrivenObservable.cs +++ b/src/client/spark/core/Utility/KeyDrivenObservable.cs @@ -32,8 +32,11 @@ namespace mbts.utils { // need to lock bc simultaneous callbacks on diff threads could generate 2 subscriptions at once, // only 1 of which would get disposed in the next callback. Disposable.dispose(ref _current_key_sub); - if (!_is_disposed) - _current_key_sub = _selector(key)?.Subscribe(_value_subject); + if (!_is_disposed) { + // IMPORTANT: do NOT subscribe _value_subject directly to the inner sequences. Subscribe with a callback delegate instead (e.g. _value_subject.OnNext). + // Reason: If a sequence 'completes' while _value_subject's subscription is active, it will enter a 'Terminated' state, and forever cease notifying observers of subsequent updates. + _current_key_sub = _selector(key)?.Subscribe(_value_subject.OnNext); + } } }