Events Flashcards

(16 cards)

1
Q

Differences between Event Emitter and Event Target

A

Event Emitter (preferred for use)
Taken from the events module
Multiple listeners per event
Fully emulates the Event Emitter from the browser
Error handling via error
Built-in events add / remove listeners

Event Target
Global variable
Only 1 listener per event
Partially emulates the browser API
No handling via error
No events add and remove listeners

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Event Target “addEventListener”

A

Add handler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Event Target “dispatchEvent”

A

Execute an event, but the argument must be new Event(“name”), not just a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Event Emitter “addListener”

A

Subscribe to event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Event Emitter “on”

A

Subscribe to event (same as addListener)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Event Emitter “removeListener”

A

Unsubscribe from event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Event Emitter “off”

A

Unsubscribe from event (same as removeListener)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Event Emitter “prependListener”

A

Will add the listener to the beginning of the emitter queue, and its event will be executed before all others (by default, it is executed in the order of the adding queue)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Event Emitter “prependOnceListener”

A

Same as prependListener, but after execution removes the listener from the emitter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Event Emitter “removeAllListeners”

A

Unsubscribe from all listeners

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Event Emitter “emit”

A

Execute event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Event Emitter “once”

A

After the first execution the event will be removed from the emitter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Event Emitter “setMaxListeners”

A

Sets the maximum number of listeners for the emitter, by default there are 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Event Emitter “listenerCount”

A

Find out how many listeners are at one event

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Event Emitter “eventNames”

A

Shows the names of events that are currently attached to the emitter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Event Emitter “listeners”

A

Shows which functions are hanging on the event