-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Description
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.