Skip to content

Instantly share code, notes, and snippets.

@Yamo93
Created October 31, 2020 21:50
Show Gist options
  • Save Yamo93/c802a4d41f00c274af67d0c36eeb6fa8 to your computer and use it in GitHub Desktop.
Save Yamo93/c802a4d41f00c274af67d0c36eeb6fa8 to your computer and use it in GitHub Desktop.
Publish method
function publish(eventName, data) {
if (!Array.isArray(subscribers[eventName])) {
return;
}
subscribers[eventName].forEach(callback => {
if (typeof callback === 'function') {
callback(data);
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment