This file contains 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
var pubsub = function(l, u, r, i) { // cool! 闭包并且初始化vars | |
return function(n, f) { | |
r = l[n] = l[n] || [], i = -1; | |
if (f && f.call) r.push(f); | |
else while (r[++i]) r[i].apply(u, arguments); | |
} | |
}({}); | |
// subscribe to event | |
pubsub("eat_cookie", function() { |