Skip to content

Commit

Permalink
change the timing to remove PropertyChanged event (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
takytank authored Jan 24, 2025
1 parent 199e8ec commit a09ae4a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public Subscription(TSubject subject, Func<TSubject, TProperty> accessor, string

private void PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (_isDisposed) throw new InvalidOperationException();
if (e.PropertyName != _propertyName && !string.IsNullOrEmpty(e.PropertyName)) return;
if (_isDisposed) throw new InvalidOperationException();

try
{
Expand All @@ -80,6 +80,7 @@ public void Dispose()
if (_isDisposed) return;

_isDisposed = true;
_subject.PropertyChanged -= PropertyChanged;
if (_onError is false)
{
try
Expand All @@ -92,7 +93,6 @@ public void Dispose()
}
}

_subject.PropertyChanged -= PropertyChanged;
_subject = default!;
_observer = null!;
_accessor = null!;
Expand Down

0 comments on commit a09ae4a

Please sign in to comment.