{"action":"created","issue":{"url":"https://api.github.com/repos/meteorhacks/flow-router/issues/96","labels_url":"https://api.github.com/repos/meteorhacks/flow-router/issues/96/labels{/name}","comments_url":"https://api.github.com/repos/meteorhacks/flow-router/issues/96/comments","events_url":"https://api.github.com/repos/meteorhacks/flow-router/issues/96/events","html_url":"https://github.com/meteorhacks/flow-router/issues/96","id":71288606,"number":96,"title":"Stop template-helper computations on route change","user":{"login":"boustanihani","id":4227548,"avatar_url":"https://avatars.githubusercontent.com/u/4227548?v=3","gravatar_id":"","url":"https://api.github.com/users/boustanihani","html_url":"https://github.com/boustanihani","followers_url":"https://api.github.com/users/boustanihani/followers","following_url":"https://api.github.com/users/boustanihani/following{/other_user}","gists_url":"https://api.github.com/users/boustanihani/gists{/gist_id}","starred_url":"https://api.github.com/users/boustanihani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boustanihani/subscriptions","organizations_url":"https://api.github.com/users/boustanihani/orgs","repos_url":"https://api.github.com/users/boustanihani/repos","events_url":"https://api.github.com/users/boustanihani/events{/privacy}","received_events_url":"https://api.github.com/users/boustanihani/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-27T13:43:57Z","updated_at":"2015-04-27T14:00:44Z","closed_at":null,"body":"In my app, when a user has 2 open browser-tabs, and he logs out in one of them, he will automatically get logged-out (and redirected to \"/\") in the other. I have a ```Tracker.autorun()``` function that checks when ```Meteor.user()``` becomes falsy and redirects using ```FlowRouter.go(\"/\")``` if the user happens to be on a **\"requireLogged\"** page.\r\n\r\nIn my profile-template I have a helper that returns ```Meteor.user().emails.pop().address```. Now when ```Meteor.logout()``` succeeds my ```Tracker.autorun()``` function is rerun first and calls ```FlowRouter.go(\"/\")``` which finally causes ```FlowLayout.render(...)```. Everything is fine, but my only problem is that the current template helpers are also being called (**one last time**) before route change happens resulting in a **\"NullPointerException\"**.\r\n\r\nI know I can avoid this by doing simple checks but IMO, ```FlowRouter.go(\"/\")``` (or maybe ``FlowLayout.render()```) should prevent all currently rendered templates from updating until route change completes. **I think this is \"natural behavior\" because there is no need to update any templates that will most probably get destroyed when a route change is just about to happen**. What do you think?"},"comment":{"url":"https://api.github.com/repos/meteorhacks/flow-router/issues/comments/96665893","html_url":"https://github.com/meteorhacks/flow-router/issues/96#issuecomment-96665893","issue_url":"https://api.github.com/repos/meteorhacks/flow-router/issues/96","id":96665893,"user":{"login":"arunoda","id":50838,"avatar_url":"https://avatars.githubusercontent.com/u/50838?v=3","gravatar_id":"","url":"https://api.github.com/users/arunoda","html_url":"https://github.com/arunoda","followers_url":"https://api.github.com/users/arunoda/followers","following_url":"https://api.github.com/users/arunoda/following{/other_user}","gists_url":"https://api.github.com/users/arunoda/gists{/gist_id}","starred_url":"https://api.github.com/users/arunoda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arunoda/subscriptions","organizations_url":"https://api.github.com/users/arunoda/orgs","repos_url":"https://api.github.com/users/arunoda/repos","events_url":"https://api.github.com/users/arunoda/events{/privacy}","received_events_url":"https://api.github.com/users/arunoda/received_events","type":"User","site_admin":false},"created_at":"2015-04-27T14:00:44Z","updated_at":"2015-04-27T14:00:44Z","body":"I this is not something we can track. Meteor.user() updated by meteor. So,\nit will invalidate all the places it tracks.\n\nThat includes both of your places. So, we can't sure which will run first.\n\nI think #96 will have something do with this, if router.go() called before\nthe helper.\n\nAnyway, you need to do checks.\nOn 2015 අප්‍රේල් 27, සඳුදා at ප.ව. 7.13 boustanihani <\nnotifications@github.com> wrote:\n\n> In my app, when a user has 2 open browser-tabs, and he logs out in one of\n> them, he will automatically get logged-out (and redirected to \"/\") in the\n> other. I have a Tracker.autorun() function that checks when Meteor.user()\n> becomes falsy and redirects using FlowRouter.go(\"/\") if the user happens\n> to be on a *\"requireLogged\"* page.\n>\n> In my profile-template I have a helper that returns\n> Meteor.user().emails.pop().address. Now when Meteor.logout() succeeds my\n> Tracker.autorun() function is rerun first and calls FlowRouter.go(\"/\")\n> which finally causes FlowLayout.render(...). Everything is fine, but my\n> only problem is that the current template helpers are also being called (*one\n> last time*) before route change happens resulting in a\n> *\"NullPointerException\"*.\n>\n> I know I can avoid this by doing simple checks but IMO, FlowRouter.go(\"/\")\n> (or maybe FlowLayout.render()`) should prevent all currently rendered\n> templates from updating until route change completes. *I think this is\n> \"natural behavior\" because there is no need to update any templates that\n> will most probably get destroyed when a route change is just about to\n> happen*. What do you think?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/meteorhacks/flow-router/issues/96>.\n>\n"}}