-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Pre-condition (guard) for multiple routes #46
Comments
You can define a function outside and use its identifier. For example (on my phone so forgive me for the simplified code and if there are mistakes):
Then use
|
Another thing: I guess it’s fine to call “replace” within the handler itself (since it waits for the next tick), but you should still ensure you |
First answer: I created Second answer: this is something I don't understand. What happens if I do not return false but just |
Well, the condition callbacks are expected to return a Boolean indicating wether the condition succeeded. If you return a truthy value, it means the router can go ahead and inject the component in the DOM. you’re then calling replace which will replace the component on the next tick. So, you get the same result - but the unwanted component will still be injected first. |
On a second though, since the replace function doesn’t have a return value, it returns undefined, which is a false-y value. So you might be ok there :) (although it’s not a documented behavior and it might change in the future) |
Oh boy. Thanks, now it's clear. I think I will go with |
Can anyone of you give the whole code this segment, like presented int he starting, but along with the solved answer? |
@ItalyPaleAle your work is amazing! Thanks a lot.
I have read all #40 and #23: an outstanding job!
Just one question: can I avoid repeating the same
wrap()
pre-condition (guard) for each route?Example:
TODAY:
WHAT I NEED:
Something like a
Protected
component to protect all routes.Is there a way?
The text was updated successfully, but these errors were encountered: