{"action":"created","issue":{"url":"https://api.github.com/repos/riot/riot/issues/1758","repository_url":"https://api.github.com/repos/riot/riot","labels_url":"https://api.github.com/repos/riot/riot/issues/1758/labels{/name}","comments_url":"https://api.github.com/repos/riot/riot/issues/1758/comments","events_url":"https://api.github.com/repos/riot/riot/issues/1758/events","html_url":"https://github.com/riot/riot/issues/1758","id":149823648,"number":1758,"title":"Proposal: support for window/body events","user":{"login":"wintercounter","id":963776,"avatar_url":"https://avatars.githubusercontent.com/u/963776?v=3","gravatar_id":"","url":"https://api.github.com/users/wintercounter","html_url":"https://github.com/wintercounter","followers_url":"https://api.github.com/users/wintercounter/followers","following_url":"https://api.github.com/users/wintercounter/following{/other_user}","gists_url":"https://api.github.com/users/wintercounter/gists{/gist_id}","starred_url":"https://api.github.com/users/wintercounter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wintercounter/subscriptions","organizations_url":"https://api.github.com/users/wintercounter/orgs","repos_url":"https://api.github.com/users/wintercounter/repos","events_url":"https://api.github.com/users/wintercounter/events{/privacy}","received_events_url":"https://api.github.com/users/wintercounter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/riot/riot/labels/feature%20request","name":"feature request","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-20T16:43:01Z","updated_at":"2016-04-20T17:55:49Z","closed_at":null,"body":"1. Describe your issue:\r\nCurrently there is no way to listen to body/window events through riot. Now you need to do this:\r\n\r\n```js\r\nthis.on('mount', function(){\r\n    window.addEventListener('resize', this.resize)\r\n})\r\n\r\nthis.on('unmount', function(){\r\n    window.removeEventListener('resize', this.resize)\r\n})\r\n\r\nresize(){\r\n    // Do stuff\r\n}\r\n```\r\n\r\nWould be nice to be able to define listeners on root definitions:\r\n```js\r\n<my-tag onwindowresize={ resize } onwindoworientationchange={ orientationChange} onbodyscroll={ scroll }>\r\n```\r\n\r\nSo this way riot would handle these events on mount/unmount just as it does now with other events.\r\nA list should be gathered about supported events, or  simply parse the attributes to find body/window in the attribute name.\r\n\r\nOFF: This is different, but I also have a similar thing in mind. Support for `one` with these events? eg. `ononeclick`\r\n\r\n`onwindoworientationchange` looks really weird btw :D\r\n\r\n2. How would you tag this issue?\r\n\r\n  - [ ] Question\r\n  - [ ] Bug\r\n  - [ ] Discussion\r\n  - [x] Feature request\r\n  - [ ] Tip\r\n  - [x] Enhancement\r\n  - [ ] Performance\r\n"},"comment":{"url":"https://api.github.com/repos/riot/riot/issues/comments/212535241","html_url":"https://github.com/riot/riot/issues/1758#issuecomment-212535241","issue_url":"https://api.github.com/repos/riot/riot/issues/1758","id":212535241,"user":{"login":"wintercounter","id":963776,"avatar_url":"https://avatars.githubusercontent.com/u/963776?v=3","gravatar_id":"","url":"https://api.github.com/users/wintercounter","html_url":"https://github.com/wintercounter","followers_url":"https://api.github.com/users/wintercounter/followers","following_url":"https://api.github.com/users/wintercounter/following{/other_user}","gists_url":"https://api.github.com/users/wintercounter/gists{/gist_id}","starred_url":"https://api.github.com/users/wintercounter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wintercounter/subscriptions","organizations_url":"https://api.github.com/users/wintercounter/orgs","repos_url":"https://api.github.com/users/wintercounter/repos","events_url":"https://api.github.com/users/wintercounter/events{/privacy}","received_events_url":"https://api.github.com/users/wintercounter/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T17:55:49Z","updated_at":"2016-04-20T17:55:49Z","body":"True. I just thought it would be nice to be able to handle this with riot and normalize event objects for cross-browser compatibility how riot currently does."}}