Here is a life example. After you press 'Toggle mouse tracker' you'll see an error in console. It happens because you should provide a reference to the handler that you want unsubscribe from. So here is the valid example.
You're right, we need a reference to the same function. That was my original code, but I removed the reference mistakenly because I thought the abstraction of the callback to handleMouseMove was unneeded. It's fixed now. Thanks Dmitriy!
Hi Reed, thank you for the cheatsheet. I found an error in Mouse Tracker example.
This code will not remove
mousemovehandler:Here is a life example. After you press 'Toggle mouse tracker' you'll see an error in console. It happens because you should provide a reference to the handler that you want unsubscribe from. So here is the valid example.
You're right, we need a reference to the same function. That was my original code, but I removed the reference mistakenly because I thought the abstraction of the callback to handleMouseMove was unneeded. It's fixed now. Thanks Dmitriy!
There's still a comment at the end of that example that dates from the original version too.