-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Stop template-bound computations on route change #96
Comments
I this is not something we can track. Meteor.user() updated by meteor. So, That includes both of your places. So, we can't sure which will run first. I think #96 will have something do with this, if router.go() called before Anyway, you need to do checks.
|
@arunoda I suppose that when we have several autoruns and something changes that affects all of them then they will get rerun in the same order they where started. I agree that in my issue I have to make sure that |
Please allow me to explain my issue in further details. When writing a template that displays user information, we assume that a user is already logged and that he won't be able to navigate to this route unless he was logged. So actually, there shouldn't be a need to check if Now the other way around, suppose we are already on a route displaying user information and the user was logged out from another browser-tab (inside the same session) or maybe from the server, then IMO there should be a way to attach a run-first hook to the routing middleware that checks if a route-change is needed while stopping all computations that would naturally get stopped when a template is destroyed. I mean stopping all So, if in our "run-first" hook function, we decide that a route-change should happen (destroying some currently rendered templates), then this should happen immediately. (Again: Why update templates that are about to get destroyed?) IMO routing-middleware should also control when templates stop updating because they are no longer needed and are about to get destroyed, so allowing a so-called "run-first" autorun hook would allow cleaner coding and also improve performance. |
Yes. This is an issue. |
related to #103 as well. |
Released version |
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 whenMeteor.user()
becomes falsy and redirects usingFlowRouter.go("/")
if the user happens to be on a "requireLogged" page.In my profile-template I have a helper that returns
Meteor.user().emails.pop().address
. Now whenMeteor.logout()
succeeds myTracker.autorun()
function is rerun first and callsFlowRouter.go("/")
which finally causesFlowLayout.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".I 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?The text was updated successfully, but these errors were encountered: