{"action":"created","issue":{"url":"https://api.github.com/repos/iron-meteor/iron-router/issues/1010","labels_url":"https://api.github.com/repos/iron-meteor/iron-router/issues/1010/labels{/name}","comments_url":"https://api.github.com/repos/iron-meteor/iron-router/issues/1010/comments","events_url":"https://api.github.com/repos/iron-meteor/iron-router/issues/1010/events","html_url":"https://github.com/iron-meteor/iron-router/issues/1010","id":47653436,"number":1010,"title":"onBeforeAction should run first, before waitOn is called","user":{"login":"oliverlloyd","id":1336821,"avatar_url":"https://avatars.githubusercontent.com/u/1336821?v=3","gravatar_id":"","url":"https://api.github.com/users/oliverlloyd","html_url":"https://github.com/oliverlloyd","followers_url":"https://api.github.com/users/oliverlloyd/followers","following_url":"https://api.github.com/users/oliverlloyd/following{/other_user}","gists_url":"https://api.github.com/users/oliverlloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/oliverlloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliverlloyd/subscriptions","organizations_url":"https://api.github.com/users/oliverlloyd/orgs","repos_url":"https://api.github.com/users/oliverlloyd/repos","events_url":"https://api.github.com/users/oliverlloyd/events{/privacy}","received_events_url":"https://api.github.com/users/oliverlloyd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/iron-meteor/iron-router/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/iron-meteor/iron-router/milestones/8","html_url":"https://github.com/iron-meteor/iron-router/milestones/Q&A","labels_url":"https://api.github.com/repos/iron-meteor/iron-router/milestones/8/labels","id":841037,"number":8,"title":"Q&A","description":"Questions and answers. Hopefully most of this can be handled on Stack Overflow. But if it ends up on Github we'll put them here.","creator":{"login":"cmather","id":262179,"avatar_url":"https://avatars.githubusercontent.com/u/262179?v=3","gravatar_id":"","url":"https://api.github.com/users/cmather","html_url":"https://github.com/cmather","followers_url":"https://api.github.com/users/cmather/followers","following_url":"https://api.github.com/users/cmather/following{/other_user}","gists_url":"https://api.github.com/users/cmather/gists{/gist_id}","starred_url":"https://api.github.com/users/cmather/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmather/subscriptions","organizations_url":"https://api.github.com/users/cmather/orgs","repos_url":"https://api.github.com/users/cmather/repos","events_url":"https://api.github.com/users/cmather/events{/privacy}","received_events_url":"https://api.github.com/users/cmather/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":20,"state":"open","created_at":"2014-10-26T17:46:06Z","updated_at":"2014-12-16T07:10:13Z","due_on":null,"closed_at":null},"comments":11,"created_at":"2014-11-03T22:28:46Z","updated_at":"2015-08-17T12:33:02Z","closed_at":null,"body":"The expected behaviour for onBeforeAction is that it is run before a route is actioned, however, since 1.0.0, in the case where a waitOn function exists, the onBeforeAction function is not called until the waitOn function returns ready. In the classic case of checking for logged in status, this could be misleading and lead to content being wrongly published.\r\n\r\n1. `$ git clone https://github.com/oliverlloyd/waitOn_issue`\r\n2. Navigate to http://localhost:3000/login\r\n3. Click link\r\n4. In console, type: `Posts.find()`\r\n\r\nIn the demo given, although you are not logged in, a subscription has been created and you can access data. True, I can (and should) make sure that I don't publish content unless a user is logged in which would prevent this but I think that the default should be reversed here, if I'm not logged in it should not try to subscribe."},"comment":{"url":"https://api.github.com/repos/iron-meteor/iron-router/issues/comments/131800084","html_url":"https://github.com/iron-meteor/iron-router/issues/1010#issuecomment-131800084","issue_url":"https://api.github.com/repos/iron-meteor/iron-router/issues/1010","id":131800084,"user":{"login":"nicejwjin","id":5439755,"avatar_url":"https://avatars.githubusercontent.com/u/5439755?v=3","gravatar_id":"","url":"https://api.github.com/users/nicejwjin","html_url":"https://github.com/nicejwjin","followers_url":"https://api.github.com/users/nicejwjin/followers","following_url":"https://api.github.com/users/nicejwjin/following{/other_user}","gists_url":"https://api.github.com/users/nicejwjin/gists{/gist_id}","starred_url":"https://api.github.com/users/nicejwjin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicejwjin/subscriptions","organizations_url":"https://api.github.com/users/nicejwjin/orgs","repos_url":"https://api.github.com/users/nicejwjin/repos","events_url":"https://api.github.com/users/nicejwjin/events{/privacy}","received_events_url":"https://api.github.com/users/nicejwjin/received_events","type":"User","site_admin":false},"created_at":"2015-08-17T12:33:01Z","updated_at":"2015-08-17T12:33:01Z","body":"@oliverlloyd damn can't find to send message or email on your github ;(\r\nI'm totally agree with his opinion even I agree with @cmather 's idea as well.\r\n\r\nBTW recently I updated my such a huge 0.9.6 Meteor Project to 1.1.3 and IronRouter was updated too.\r\nI crashed this problem because I used to initial some conditions including 'wait on parameter for sub'.\r\n\r\nOn this pattern changed, actually my app was totally broken cause waitOn is called before onBeforeAction by the way, so I migrated almost all iron router life cycles to Blaze one.\r\n\r\nI know @cmather 's pattern could be powerful, BUT, I'm for sure that every application need to be initial their data before do something, importantly, onRun is called only one time when the route called, and this is not called when hot code deployed or template re-rendered by any reasons. \r\nThis was perfect place to initial all data.\r\n\r\nSo my question is this. Which hook could I initial data only one time without making any annoying codes such as running only one time at the top of the waiting things??\r\n\r\n"}}