Created
December 15, 2012 20:40
-
-
Save ksafranski/4298991 to your computer and use it in GitHub Desktop.
Really small jQuery pub/sub script
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
| // See example at http://jsfiddle.net/fluidbyte/AhBKq/ | |
| var broadcast = { | |
| speak: function (name, message) { | |
| $(document).trigger(name, message); | |
| }, | |
| listen: function (name, callback) { | |
| $(document).bind(name, function (e, message) { | |
| if (callback && typeof (callback) === "function") { | |
| callback(message); | |
| } | |
| }); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment