MCPcopy
hub / github.com/glidejs/glide / on

Method on

src/core/event/events-bus.js:20–43  ·  view source on GitHub ↗

* Adds listener to the specifed event. * * @param {String|Array} event * @param {Function} handler

(event, handler)

Source from the content-addressed store, hash-verified

18 * @param {Function} handler
19 */
20 on (event, handler) {
21 if (isArray(event)) {
22 for (let i = 0; i < event.length; i++) {
23 this.on(event[i], handler)
24 }
25
26 return
27 }
28
29 // Create the event's object if not yet created
30 if (!this.hop.call(this.events, event)) {
31 this.events[event] = []
32 }
33
34 // Add the handler to queue
35 const index = this.events[event].push(handler) - 1
36
37 // Provide handle back for removal of event
38 return {
39 remove () {
40 delete this.events[event][index]
41 }
42 }
43 }
44
45 /**
46 * Runs registered handlers for specified event.

Callers 15

bindFunction · 0.45
images.jsFile · 0.45
translate.jsFile · 0.45
bindFunction · 0.45
resize.jsFile · 0.45
breakpoints.jsFile · 0.45
move.jsFile · 0.45
bindSwipeStartFunction · 0.45
bindSwipeMoveFunction · 0.45
bindSwipeEndFunction · 0.45
swipe.jsFile · 0.45
clones.jsFile · 0.45

Calls 1

isArrayFunction · 0.90

Tested by

no test coverage detected