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
addEventListenerOnce method #473
Comments
Agree this would be nice to have in future. |
Great. I need this method for puposes of my development. I want to create it right now. And when it will be clear for me how to make a pull request I will sent new code for your recenzasion (in order you could add it to preferable releaze). Is this way suitable to you? |
Sure, looking forward to your pull! |
I made a pull request |
also I created another two methods that were very useful for me. Perhaps they will suit for someone else
Should I add them to pull request mentioned above or make a new one? |
Cvisto, Could you please provide your code for "hasEventListener(type, fn, context)" and "clearEventListeners(type)". Thanks a lot! |
methods start from here https://github.com/cvisto/Leaflet/blob/has_clearEventListeners/src/core/Events.js#L23. You can get them from there or just merge my has_clearEventListeners branch |
This one seems like a bit of a no-brainer here. Definitely think it should be implemented. Odd in-fact that it hasn't already. Have had to do on-offs three times now in the same application which isn't so neat and tidy. Add it guys! :) |
Done. |
I was faced with the need to add the same listener function to different objects while listener of one object has to fire once and listener of another object has to fire any time event is created.
Now I should resolve this task like this:
myFunc(){
alert('clicked');
}
myFunc_Once(){
marker1.removeEventListener('click', myFunc_Once);
myFunc();
}
Init(){
marker1.addEventListener('click', myFunc_Once);
marker2.addEventListener('click', myFunc);
}
It would be more easy to use addEventListenerOnce wich will make event listener to remove itself after firing.
The text was updated successfully, but these errors were encountered: