{"action":"opened","issue":{"url":"https://api.github.com/repos/ecomfe/uioc/issues/46","repository_url":"https://api.github.com/repos/ecomfe/uioc","labels_url":"https://api.github.com/repos/ecomfe/uioc/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/ecomfe/uioc/issues/46/comments","events_url":"https://api.github.com/repos/ecomfe/uioc/issues/46/events","html_url":"https://github.com/ecomfe/uioc/issues/46","id":153216981,"number":46,"title":"aop 配置语法支持","user":{"login":"Exodia","id":2111298,"avatar_url":"https://avatars.githubusercontent.com/u/2111298?v=3","gravatar_id":"","url":"https://api.github.com/users/Exodia","html_url":"https://github.com/Exodia","followers_url":"https://api.github.com/users/Exodia/followers","following_url":"https://api.github.com/users/Exodia/following{/other_user}","gists_url":"https://api.github.com/users/Exodia/gists{/gist_id}","starred_url":"https://api.github.com/users/Exodia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Exodia/subscriptions","organizations_url":"https://api.github.com/users/Exodia/orgs","repos_url":"https://api.github.com/users/Exodia/repos","events_url":"https://api.github.com/users/Exodia/events{/privacy}","received_events_url":"https://api.github.com/users/Exodia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-05T11:46:38Z","updated_at":"2016-05-05T11:46:38Z","closed_at":null,"body":"目前设计的配置语法如下：\r\n\r\n```javascript\r\nlet iocConfig = {\r\n    components: {\r\n        myComponent: {\r\n            creator() {\r\n                this.doSomething = function () {};\r\n                this.doSomething1 = function () {};\r\n            }\r\n        },\r\n        log: {\r\n            creator() {\r\n                return {\r\n                    start: () => console.log('start'),\r\n                    end: () => console.log('end')\r\n                }\r\n            }\r\n        }\r\n    },\r\n    // aop 总配置\r\n    aopConfig: {\r\n        // 针对具体组件的配置\r\n        myComponent: {\r\n            // 每个组件的通知器\r\n            advisors: [\r\n                {\r\n                    // 字符串匹配\r\n                    matcher: 'doSomething',\r\n                    // 具体通知\r\n                    advices: {\r\n                        // doSomething 执行前执行 log.start 方法\r\n                        before: 'log.start',\r\n                        // doSomething 执行完执行 log.end 方法\r\n                        afterReturning: 'log.end'\r\n                    }\r\n                },\r\n                {\r\n                    matcher: 'doSomething1',\r\n                    advices: {\r\n                        before: (...args) => console.log(args)\r\n                    }\r\n                },\r\n                {\r\n                    matcher: /doSomething/,\r\n                    advices: {\r\n                        after: () => console.log('after doSomething')\r\n                    }\r\n                }\r\n            ]\r\n        }\r\n    }\r\n};\r\n\r\n// 打印 start end after doSomething\r\nioc.getComponent('myComponent').then(myComponent => myComponent.doSomething());\r\n```"}}