Created
July 20, 2017 16:57
-
-
Save betterkenly/3f6ba4bc7b0ce25bae0fe46a2bd0479c to your computer and use it in GitHub Desktop.
message bus
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
let messageBus = { | |
subscribers: [], | |
publish: (message) => { | |
this.subscribers.forEach((subscriber) => { | |
subscriber.fn(message); | |
}); | |
}, | |
subscribe: (type, subscriber, fn) => { | |
this.subscribers.push({ | |
'type': type, | |
'subscriber': subscriber, | |
'fn': fn | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment