Skip to content

Commit

Permalink
Don't subscribe to inner observable if not active.
Browse files Browse the repository at this point in the history
When subscribing to a `PropertySetterBindingInstance`, if the owner style is not active then there's no need to subscribe to the inner observable as this can cause resource lookups etc. Part of fixing #5027.
  • Loading branch information
grokys committed Nov 16, 2020
1 parent 585f618 commit c789c90
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void Activate()
{
if (!_isActive)
{
_innerSubscription ??= _binding.Observable.Subscribe(_inner);
_isActive = true;
PublishNext();
}
Expand All @@ -102,6 +103,8 @@ public void Deactivate()
if (_isActive)
{
_isActive = false;
_innerSubscription?.Dispose();
_innerSubscription = null;
PublishNext();
}
}
Expand Down Expand Up @@ -148,7 +151,10 @@ void IObserver<BindingValue<T>>.OnNext(BindingValue<T> value)

protected override void Subscribed()
{
_innerSubscription = _binding.Observable.Subscribe(_inner);
if (_isActive)
{
_innerSubscription = _binding.Observable.Subscribe(_inner);
}
}

protected override void Unsubscribed()
Expand Down

0 comments on commit c789c90

Please sign in to comment.