-
Notifications
You must be signed in to change notification settings - Fork 192
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() vs. {...}.redirect() #100
Comments
We are doing some checks on FlowRouter.go to stop running route if called multiple times. Which means routes are idempotent. I like that idea. We need to do it for .redirect as well. But, I'm still quite not sure this is the right way or not. May be I need to trust my gut feeling. Handling login related stuff is pretty messy now. We need to find a way for that. I'll work on that, once I fixed major bugs. |
I think I'll keep both .redirect() and .go() idempotent. Then we can have .reload() api. |
@arunoda I think the idempotency is fine, but if you make both .go() and +1 for that. Question, what is the difference between redirect and go (assuming both are
|
FlowRouter.redirect() can be used inside middlewares to redirect the route. Then it gives us clean history. see: https://visionmedia.github.io/page.js/ But, we need to complete this API a bit and add more docs. |
I see, that clears things up. Thanks arunoda.
|
@arunoda currently I (and I'm sure others) are relying on at least one of Thanks!
|
I'm closing this favour of the reload API. |
can you share your loginMiddleware |
I noticed something when trying the former solution.
FlowRouter.go(pathA)
will not runpathA
's middleware if I'm already atpathA
. However, if I useFlowrouter.redirect(pathA)
, the route will be run fully with middleware (like expected) regardless of what path I'm currently at.Is this intended behavior?
Since FR is non-reactive by design, a common pattern is to rerun a route in light of new information. This seems to go against the design of FR (because that's pretty much what Iron Router does) so I am wondering whether or not its a better idea to render a different template instead of rerouting.
USE CASE: I have
loginMiddleware
which is very basic and renders aloginTemplate
if the user isn't logged in. Once the user signs in from this view, I want the route to be re-run in light of the fact that she is now signed in. In the logging in callback function, IFlowRouter.redirect(currentPath)
and all is well. Instead I'm thinking it might be a better idea toFlowLayout.render('layout',ifLoggedInTemplates)
in the callback. Thoughts?Another solution is to implement a separate sign-in route which is hit in the loginMiddleware if not signed in, and keep n=1 route history, and then just redirect back to the previous page after the user signs in.
The text was updated successfully, but these errors were encountered: