We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
//摘自alloyTeam团队的曾探·著
var imitate = (function() { var imitate = { clientList: [], listen: function(key, fn) { if (!this.clientList[key]) { this.clientList[key] = []; } this.clientList[key].push(fn); }, trigger: function() { var key = [].shift.call(arguments); var fns = this.clientList[key]; // 如果没有对应的绑定消息 if (!fns || fns.length === 0) { return false; } for (var i = 0, fn; fn = fns[i++];) { // arguments 是 trigger带上的参数 fn.apply(this, arguments); } } } return function() { return Object.create(imitate); } })(); var eventModel = imitate(); //得到上面的对象 eventModel.listen("jimmy",function(){console.log("jimmy");}); //jimmy eventModel.trigger("jimmy");
The text was updated successfully, but these errors were encountered:
No branches or pull requests
//摘自alloyTeam团队的曾探·著
The text was updated successfully, but these errors were encountered: