Created
October 31, 2020 21:48
-
-
Save Yamo93/5841d53a0dcb4fa75b6085fe6faaf73e to your computer and use it in GitHub Desktop.
Subscribe 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 subscribe(eventName, callback) { | |
if (!Array.isArray(subscribers[eventName])) { | |
subscribers[eventName] = []; | |
} | |
subscribers[eventName].push(callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment