Last active
December 26, 2022 16:57
-
-
Save an-parubets/3368aef2d9d0b21cea0aab620b041b1b to your computer and use it in GitHub Desktop.
EventEmitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {string} eventName | |
* @param {any} args | |
*/ | |
emit(eventName, args) { | |
const event = this.events[eventName]; | |
event && event.forEach(callback => callback.call(null, args)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment