Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sanjayabc1234/71ad3f3598f51ac4d0971f58eab26710 to your computer and use it in GitHub Desktop.
Save sanjayabc1234/71ad3f3598f51ac4d0971f58eab26710 to your computer and use it in GitHub Desktop.
emit(name, data) {
if (!this._events[name]) {
throw new Error(`Can't emit an event. Event "${name}" doesn't exits.`);
}
const fireCallbacks = (callback) => {
callback(data);
};
this._events[name].forEach(fireCallbacks);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment