You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding an Observer to an Observable requires you provide an Owner, and produces a Subscription. Normally the owner should take care of killing this subscription, but you can also kill it manually before the owner decides to do that.
The right way to do this is to call subscription.kill().
However, Airstream also provides a removeObserver(observer) method on Observable. While it does correctly remove the observer from the observable, it does not call subsription.kill() because it has no reference to the subscription. This means the Owner continues to keep a reference to the subscription (and thus to both observable and observer) until the Owner decides to kill them.
This is an error in my API design, and is contrary to users expectations. I will fix this one way or another, likely by removing the removeObserver method. However, the exact solution depends on how I decide to implement raquo/Laminar#33.
For now, avoid using the removeObserver method in favour of subscription.kill
The text was updated successfully, but these errors were encountered:
raquo
changed the title
Bug: removeObserver can cause a (usually minor) memory leak
Bug: Observable.removeObserver can cause a (usually minor) memory leak
Oct 6, 2018
Adding an Observer to an Observable requires you provide an Owner, and produces a Subscription. Normally the owner should take care of killing this subscription, but you can also kill it manually before the owner decides to do that.
The right way to do this is to call
subscription.kill()
.However, Airstream also provides a
removeObserver(observer)
method on Observable. While it does correctly remove the observer from the observable, it does not callsubsription.kill()
because it has no reference to the subscription. This means the Owner continues to keep a reference to the subscription (and thus to both observable and observer) until the Owner decides to kill them.This is an error in my API design, and is contrary to users expectations. I will fix this one way or another, likely by removing the removeObserver method. However, the exact solution depends on how I decide to implement raquo/Laminar#33.
For now, avoid using the removeObserver method in favour of subscription.kill
The text was updated successfully, but these errors were encountered: