-
-
Save stephencoe/4342680 to your computer and use it in GitHub Desktop.
Revisions
-
fideloper revised this gist
Jun 2, 2012 . No changes.There are no files selected for viewing
-
Chris Fidao revised this gist
May 5, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ /* See it in action: http://jsbin.com/iyinux/edit#javascript,html,live Also Fun: http://jsbin.com/oyanih/7/edit#javascript,html,live Better Fun: http://jsbin.com/uhakaw/34/edit#javascript,html,live */ /* EXAMPLE USE OF JAVASCRIPT PUBSUB - -
Chris Fidao revised this gist
May 3, 2012 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ /* See it in action: http://jsbin.com/iyinux/edit#javascript,html,live Also Fun: http://jsbin.com/oyanih/7/edit#javascript,html,live */ /* EXAMPLE USE OF JAVASCRIPT PUBSUB - https://github.com/mroderick/PubSubJS -
Chris Fidao created this gist
May 3, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,79 @@ /* See it in action: http://jsbin.com/iyinux/edit#javascript,html,live */ /* EXAMPLE USE OF JAVASCRIPT PUBSUB - https://github.com/mroderick/PubSubJS *************************************************************/ /* Conveniently global for demo This is assigned PubSub object after JS file is loaded *************************************************************/ var pubber = false; /* Messengers send and receive messages **************************************************************************/ var messenger1 = { token: false, message: '', receive: function(mssg,data) { console.log('Messender 1 received:',data); }, send: function() { console.log('Messender 1 sending:','Messenger 1 message'); pubber.publish('mssg', 'Messenger 1 message'); } }; var messenger2 = { token: false, message: '', receive: function(mssg, data) { console.log('Messender 2 received:',data); }, send: function() { console.log('Messender 2 sending:','Messenger 2 message'); pubber.publish('mssg', 'Messenger 2 message'); } }; /* App controller to demo PubSub **************************************************************************/ var app = { init: function(Pubber) { messenger1.token = Pubber.subscribe('mssg', messenger1.receive); messenger2.token = Pubber.subscribe('mssg', messenger2.receive); }, rollThisJoint: function() { messenger1.send(); messenger2.send(); } }; /* Handle loading PubSub JS Asynchronously because of how JSBin works. **************************************************************************/ (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.onload = function() { pubber = PubSub; app.init(PubSub); app.rollThisJoint(); }; ga.src = 'https://raw.github.com/mroderick/PubSubJS/master/src/pubsub.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();