Skip to content

Instantly share code, notes, and snippets.

@brycehamrick
Last active December 12, 2015 01:49
Show Gist options
  • Save brycehamrick/4694331 to your computer and use it in GitHub Desktop.
Save brycehamrick/4694331 to your computer and use it in GitHub Desktop.
Subscribing to a Backplane channel and testing type
(function() {
if (typeof window.Backplane !== 'function' || parseInt(Backplane.version) !== 2)
return;
/**
* Callback function to be executed on BP ready
*/
function bp_ready_callback() {
Backplane.subscribe(function(message){
switch(message.type) {
case 'identity/login':
// Do something with message
break;
default:
// Don't do anything if this isn't a type we recognize
}
}
}
// Pass in function from above
Backplane(bp_ready_callback);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment