Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic addEventListener and removeEventListener, in case I need it later
var eventListeners = {
eventName: []
};
function addEventListener(type, listener) {
var listeners = eventListeners[type];
if (listeners) {
listeners.push(listener);
}
}
function removeEventListener(type, listener) {
var listeners = eventListeners[type];
if (listeners) {
let index = listeners.indexOf(listener);
if (index > -1) {
listeners.splice(index, 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.