-
Notifications
You must be signed in to change notification settings - Fork 195
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
FlowRouter.go() should stop unneeded computations #292
Comments
This is not something we can track. In this case, logout happens whithin a layout. So, router has no control over that. Here you are watching the user() via also a tracker and do a redirect. So, template helper could fire before the redirect tracker. That's not we can control. |
But shouldn't the user template get destroyed immediately? I mean |
Currently, even if we it gets calls before that, there is a global tracker inside where FlowRouter.go() pass an redirect action. It waits until all other computations end. It's best to do something like this: {{#if currentUser}}
<div>
{{> Template.dynamic template=main}}
</div>
{{/if}} We'll can do immediate route change when we remove subs logic from the router. I'm having some ideas. Let's see. I mark this as a bug, until we found a built-in solution. |
Thanks, I just hope FlowRouter/BlazeLayout would offer some way to interrupt/hook into template specific computations (helpers, subscriptions, autoruns etc...) and allow stopping them immediatly if needed... This would then eliminate the need for traditional "if-checks" like in the workaround you mentioned and result in cleaner code |
There is another small issue I noticed, if you open the page http://reactive-flowing.meteor.com/ and you are still not signed in, try clicking directly on "User", the user page will not show and you will be redirected to "Home" but the browser path will not be updated accordingly... I tried calling |
I've hacked together a full white screen w/spinner between routes where I can add one line to all of my slow to render templates. Template code
Router code
Other thoughts & caveatsThis could easily be extended to prevent rendering at all between routes, but the only way I saw to do that was with an My code is using _callbacks which I don't like. I tried using Template[name] by grabbing the name from the instance but that didn't work. This code potentially creates multiple onRendered callbacks, but it would mostly be a minor optimization to prevent that. |
I am reopenning issue #96 because it seems to be still existing...
To reproduce, click on SignIn, then swith to the User page and finally SignOut, you should get this on your console:
After calling
FlowRouter.go()
the templates that are about to get destroyed should no longer update. (review discussion in #96 for further details)Repo: https://github.com/boustanihani/reactive-flowing
Deployment: http://reactive-flowing.meteor.com
And here is my code:
The text was updated successfully, but these errors were encountered: