Skip to content

Instantly share code, notes, and snippets.

@noomz
Last active December 13, 2015 18:19
Show Gist options
  • Save noomz/4954573 to your computer and use it in GitHub Desktop.
Save noomz/4954573 to your computer and use it in GitHub Desktop.
SimpleBroadcast = (function () {
var sub = {};
return {
publish: function (topic, data) {
data = data || {};
(sub[topic] || []).forEach(function (func) {
func(data);
});
},
subscribe: function (topic, func) {
sub[topic] = sub[topic] || [];
sub[topic].push(func);
}
};
})();
@pphetra
Copy link

pphetra commented Feb 15, 2013

h นั่นเปลี่ยนชื่อเป็น topic ดีกว่า

@noomz
Copy link
Author

noomz commented Oct 26, 2014

update แล้วคร้าบบ เอา jquery ออกด้วย

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment