Created
October 31, 2020 21:50
-
-
Save Yamo93/c802a4d41f00c274af67d0c36eeb6fa8 to your computer and use it in GitHub Desktop.
Publish method
This file contains 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
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