Unbinding or .off() ?
See original GitHub issueSorry if this is a silly question or the wrong place to ask it but I was curious, is there a method for unbinding postRobot listeners?
For example: Previously in my react components I was doing something like…
componentWillMount() {
window.addEventListener('message', this.onMessage);
}
componentWillUnmount() {
window.removeEventListener('message', this.onMessage);
}
Now with postRobot
I have something like…
componentWillMount() {
postRobot.on('ON_MESSAGE', { window: window.parent }, (event) => {
this.onMessage(event);
});
}
So i was wondering do I need to unbind? I was imagining something like…
componentWillUnmount() {
postRobot.off('ON_MESSAGE');
}
Or is this automatically handled since each request is hashed as a new postMessage?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
What is the difference between jQuery off() and unbind()
Using off is the modern way, unbind is the old way. Use off .
Read more >jQuery unbind() Method - W3Schools
The unbind() method was deprecated in version 3.0. Use the off() method instead. The unbind() method removes event handlers from selected elements. This...
Read more >.unbind() | jQuery API Documentation
A string containing one or more DOM event types, such as "click" or "submit," or custom event names. Unbinds the corresponding 'return false'...
Read more >What's the relationship between jQuery bind/unbind and on/off?
(Delegated events are bound to a parent element rather than the element that we want to handle the event for.
Read more >Binding and unbinding of event handlers - plainJS
Binding and unbinding of event handlers. How to attach or detach a handler function to an event, such as click, focus, or submit....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Definitely makes sense. Let me re-open this issue while I mull it over.
hmm, nevermind! It looks like those “global” variables are still scoped to my component. Not very clean but I don’t really care since it seems to work well! Thanks for this library!