-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix($mdInteraction): clean up events on $rootScope destroy #11641
Conversation
41a35d0
to
7cb7b0e
Compare
I have another version that squishes the init and deregister methods into one that is passed 'on' or 'off', but thought this might be overly clever and less easily understood. It does have the have the benefit of having one place where events are manipulated so you don't have to worry about keeping both the init and deregister methods in sync. Let me know if that is preferred. 🐔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thank you!
Is there any way to verify this fix in a unit test? Maybe destroy the the rootScope and then check if the handlers are still there?
In the commit message, can you please change |
this prevents unit tests from leaking memory Fixes angular#11493
7cb7b0e
to
c5e2616
Compare
Changed 🐔
I added unit tests that see if the lastInteractionType is modified after an event is fired. 🐔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
this prevents unit tests from leaking memory
Fixes: #11493
PR Checklist
Please check that your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently the $mdInteraction service registers when invoked. This causes a memory leak in unit tests because nothing is in place to clean up the events.
Issue Number: #11493
What is the new behavior?
Now on the $destroy event of rootScope the events registered will be unregistered.
Does this PR introduce a breaking change?
Other information