Skip to content

Instantly share code, notes, and snippets.

@shellscape
Created April 24, 2017 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shellscape/fdcd98aa743b683eb4539336b06200c9 to your computer and use it in GitHub Desktop.
Save shellscape/fdcd98aa743b683eb4539336b06200c9 to your computer and use it in GitHub Desktop.
signal event debugging
(function (root) {
'use strict';
var scope = 'bananas', // whatever your company global variable is
enabled = /(\?|&)debug=true/.test(document.location.search);
if (!root[scope) {
root[scope] = {
signal: {}
};
};
function debug () {
if (!enabled) {
return;
}
var args = Array.prototype.slice.call(arguments);
console.info.apply(console, ['Signal: debug →'].concat(args));
}
debug.isEnabled = function () {
return enabled;
};
debug.enable = function () {
enabled = true;
};
debug.disable = function () {
enabled = false;
};
root[scope].signal.debug = debug;
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment