10 examples of 'event listeners javascript list' in JavaScript

Every line of 'event listeners javascript list' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
61addEventListener(name,listener){
62 if(!this[EVENT_SYMBOL][name])
63 this[EVENT_SYMBOL][name] = new Set;
64 this[EVENT_SYMBOL][name].add(listener);
65}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

21addListener(listener) {
22 this.listeners.push(listener);
23}
511function createEventListener(element, eventType, script) {
512 if (!script) {
513 return;
514 }
515
516 try {
517 var action = new Function(script);
518 element.addEventListener(eventType, action);
519 } catch (ex) {
520 if (verbose) {
521 console.log('on' + eventType + ': ' + ex);
522 }
523 }
524}
11addListener(type, callback) {
12 this.listeners.get(type).push(callback);
13}
81function executeEventListeners(listeners) {
82 for (var parameters = [],
83 $__6 = 1; $__6 < arguments.length; $__6++)
84 parameters[$__6 - 1] = arguments[$__6];
85 listeners.forEach(function(listener) {
86 try {
87 listener.apply(null, parameters);
88 } catch (error) {
89 console.error("An event listener threw an error", error);
90 }
91 });
92}
9addListener(event, listener){
10 if (!Array.isArray(this.__events__[event]))
11 this.__events__[event] = []
12 this.__events__[event].push(listener)
13 return this
14}
40removeEventListeners(listeners: Listeners = this.props.listeners) {
41 if (canUseEventListeners) {
42 listeners.forEach(({ target, event, handler, options }: Listener) => {
43 const node = this.getTargetNode(target);
44 node && node.removeEventListener(event, handler, options);
45 });
46 }
47}
34public addEventListener(event: string, callback: (sender: any, args: any) => void)
35{
36 if (this.events === undefined)
37 {
38 this.events = {};
39 }
40
41 if (this.events[event] === undefined)
42 {
43 this.events[event] = {
44 callbacks: []
45 };
46 }
47
48 this.events[event].callbacks.push(callback);
49}
95private addAllListeners() {
96 for (const listener of this.listeners) {
97 if (listener.listening === false) {
98 this.log.log(
99 `Lazily adding event listener for "${listener.eventType}".`,
100 );
101 this.addEvLis(listener);
102 }
103 }
104}
89addListeners (event, listener) {
90 return this.manipulateListeners(false, event, listener)
91}

Related snippets