Event Handle that is created by EventHandler and can be used for easier event removal and management.
const evt = obj.on('test', (a, b) => { console.log(a + b);});obj.fire('test');evt.off(); // easy way to remove this eventobj.fire('test'); // this will not trigger an event Copy
const evt = obj.on('test', (a, b) => { console.log(a + b);});obj.fire('test');evt.off(); // easy way to remove this eventobj.fire('test'); // this will not trigger an event
// store an array of event handleslet events = [ ];events.push(objA.on('testA', () => { }));events.push(objB.on('testB', () => { }));// when needed, remove all eventsevents.forEach((evt) => { evt.off();});events = [ ]; Copy
// store an array of event handleslet events = [ ];events.push(objA.on('testA', () => { }));events.push(objB.on('testB', () => { }));// when needed, remove all eventsevents.forEach((evt) => { evt.off();});events = [ ];
source object of the event.
Name of the event.
Function that is called when event is fired.
Object that is used as this when event is fired.
this
Optional
If this is a single event and will be removed after event is fired.
True if event has been removed.
Remove this event from its handler.
Event Handle that is created by EventHandler and can be used for easier event removal and management.
Example
Example