{"action":"created","issue":{"url":"https://api.github.com/repos/wmy19930609/baseJs/issues/3","labels_url":"https://api.github.com/repos/wmy19930609/baseJs/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/wmy19930609/baseJs/issues/3/comments","events_url":"https://api.github.com/repos/wmy19930609/baseJs/issues/3/events","html_url":"https://github.com/wmy19930609/baseJs/issues/3","id":107637066,"number":3,"title":"js练习-2","user":{"login":"wmy19930609","id":8522841,"avatar_url":"https://avatars.githubusercontent.com/u/8522841?v=3","gravatar_id":"","url":"https://api.github.com/users/wmy19930609","html_url":"https://github.com/wmy19930609","followers_url":"https://api.github.com/users/wmy19930609/followers","following_url":"https://api.github.com/users/wmy19930609/following{/other_user}","gists_url":"https://api.github.com/users/wmy19930609/gists{/gist_id}","starred_url":"https://api.github.com/users/wmy19930609/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmy19930609/subscriptions","organizations_url":"https://api.github.com/users/wmy19930609/orgs","repos_url":"https://api.github.com/users/wmy19930609/repos","events_url":"https://api.github.com/users/wmy19930609/events{/privacy}","received_events_url":"https://api.github.com/users/wmy19930609/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-22T03:01:15Z","updated_at":"2015-09-23T01:57:49Z","closed_at":null,"body":"**描述：**\r\n实现E.on('xxx',function(argument) {//....})、E.once()和E.emit('xxx',{asdasd})；"},"comment":{"url":"https://api.github.com/repos/wmy19930609/baseJs/issues/comments/142471098","html_url":"https://github.com/wmy19930609/baseJs/issues/3#issuecomment-142471098","issue_url":"https://api.github.com/repos/wmy19930609/baseJs/issues/3","id":142471098,"user":{"login":"wmy19930609","id":8522841,"avatar_url":"https://avatars.githubusercontent.com/u/8522841?v=3","gravatar_id":"","url":"https://api.github.com/users/wmy19930609","html_url":"https://github.com/wmy19930609","followers_url":"https://api.github.com/users/wmy19930609/followers","following_url":"https://api.github.com/users/wmy19930609/following{/other_user}","gists_url":"https://api.github.com/users/wmy19930609/gists{/gist_id}","starred_url":"https://api.github.com/users/wmy19930609/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmy19930609/subscriptions","organizations_url":"https://api.github.com/users/wmy19930609/orgs","repos_url":"https://api.github.com/users/wmy19930609/repos","events_url":"https://api.github.com/users/wmy19930609/events{/privacy}","received_events_url":"https://api.github.com/users/wmy19930609/received_events","type":"User","site_admin":false},"created_at":"2015-09-23T01:57:49Z","updated_at":"2015-09-23T01:57:49Z","body":"```javascript\r\n<script>\r\n\r\n\tvar E = {};\r\n\r\n\tE.on = function(evtName, callback){\r\n\t\tvar fns = evtName.split(' ');\r\n\t\tvar allExec = true;\r\n\t\t\r\n\t\tif(fns.length > 1){//多个\r\n\t\t\tfor(var i = 0; i < fns.length; i++){\r\n\t\t\t\tallExec = allExec && this[fns[i]].isExcu;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif(allExec){\r\n\t\t\t\tthis[evtName] = this[evtName] || [];\r\n\t\t\t\tthis[evtName].push(callback);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis[evtName] = this[evtName] || [];\r\n\t\t\tthis[evtName].push(callback);\r\n\t\t}\r\n\r\n\t}\r\n\t\r\n\tE.off = function(evtName) {\r\n\t\tdelete this[evtName];\r\n\t}\r\n\r\n\tE.emit = function(evtName, args){\r\n\t\tvar fnQueue = this[evtName];\r\n\t\tif(fnQueue){\r\n\t\t\tfnQueue.isExcu = true;\r\n\t\t\tfor(var i = 0; i < fnQueue.length; i++){\r\n\t\t\t\tfnQueue[i](args);\r\n\t\t\t}\r\n\t\t}\r\n\t};\r\n\r\n\tE.once = function(evtName, callback){\r\n\t\tthis.on(evtName,callback);\r\n\t\tthis.on(evtName,function() {\r\n\t\t\tE.off(evtName);\r\n\t\t});\r\n\t};\r\n\r\n\tE.on('getNa1', function(data){console.log(data);});\r\n\tE.on('getN2', function(data){console.log(data);});\r\n\tE.on('getN3', function(data){console.log(data);});\r\n\r\n\tE.emit('getNa1', 'haha');\r\n\tE.emit('getN2', 'heha');\r\n\t// E.emit('getN3', 'haha');\r\n\r\n\tE.on('getNa1 getN2 getN3',function(paramsArr) {\r\n\t\tconsole.log(paramsArr);\r\n\t});\r\n\r\n\tE.emit('getNa1 getN2 getN3',['hah','sss','ddd']);\r\n</script>\r\n```\r\n"}}