Skip to content

Instantly share code, notes, and snippets.

@bjrn
Last active March 1, 2016 14:15
Show Gist options
  • Save bjrn/b1760d8bc2d9a52aa137 to your computer and use it in GitHub Desktop.
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
// vngage.subscribe( message, func );
vngage.subscribe('banner:join', function () {
console.log('banner:join triggered');
});
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