Last active
March 1, 2016 14:15
-
-
Save bjrn/b1760d8bc2d9a52aa137 to your computer and use it in GitHub Desktop.
simple vngage boot script that allows for using vngage.subscribe() in your code before the script has loaded
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
// vngage.subscribe( message, func ); | |
vngage.subscribe('banner:join', function () { | |
console.log('banner:join triggered'); | |
}); |
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
window.vngage = window.vngage || {}; | |
if (!vngage.subscribe) { | |
vngage._subscriptions = vngage._subscriptions || {}; | |
vngage.subscribe = function(msg, func) { | |
if (typeof func !== 'function') { return false; } | |
if (!this._subscriptions.hasOwnProperty(msg)) { this._subscriptions[msg] = []; } | |
this._subscriptions[msg].push({func: func}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment