-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to unsubscribe from event listeners #193
Comments
@patrix Thanks for referencing that code. I'll close this issue. For reference, my workaround in React looks something like this:
|
Fixes mapbox#193 Inspired by tristen commit ref mapbox#40
Fixes mapbox#193 Inspired by tristen commit ref mapbox#40
Can you please elaborate the second method a bit more ? |
@neeleshbisht99 patrix coded it... not sure how much clearer it can be than that... #194 |
@hutch120 I got it , thanks |
It's still ambiguous, it doesn't seem to comment on how it guarantees function matches. For instance, does it unsubscribe: map.on('zoom' () => handleZoom());
map.off('zoom' () => handleZoom()); My understanding is that this might now? If not, then that's a gotcha that isn't made clear. |
Hi All,
I've just spent quite a while tracking down an issue that results in multiple triggering of the
on('xxxx')
functions.I have a react application that moves between pages, and loads/unloads components as it should. But, when I unload this module, it maintains the listener state, despite calling removeControl.
Essentially the issue (other than annoyance of multiple callbacks) is that eventually you will hit the maxListeners limit of 10 if you call the
on
handlers. E.g. on('route') because there is no way to unregister listeners, not even by using removeControl.I've got a workaround in my code that sets a static variable, and checks that before registering the listener, but
feelsbadman
.I think there are two things that could resolve this.
and/or
un
function to remove a listener. A bit harder..The text was updated successfully, but these errors were encountered: