-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
router guard and async #125
Comments
I also have this issue. I need to verify that the user is connected with the firebase API. |
Hi! let routes;
routes = new Map();
routes.set("/protected-route", MyWrapper); And in {#await isAuthenticated()}
// Show progress
{:then value}
// Load component with Loadable or svelte:component
<Loadable loader={AccessGrantedComponent} />
{:catch error}
// Show error
{/await} |
I have the same issue, and I feel like the suggestion by @BogdanDarius isn't general-purpose enough to (easily) work on many pages (please correct me if I misunderstood something). |
Promise and lazy routing are on the roadmap. |
That's great to hear @BogdanDarius , really looking forward to this! |
Encountering this issue with firebase authentication as well, would love to see this feature implemented. |
FWIW, I now call a |
I do the same as @Dan1ve in my own code. If every single route requires authentication, I check it in a function that's called at the beginning of the page's execution, in the main.js file (outside of the Svelte app) |
@Manborough support for async functions in route pre-conditions has been added to 3.0 (WIP branch) and will be released with version 3.0 soon 🚀 |
This also includes a refactoring to leverage async/await more Fixes #125
Is there a particular way I need to use async functions within the wrap function?
I'm trying to check authorisation from my API roughly like this.
but I'm finding the route loads before the results from the api return.
The text was updated successfully, but these errors were encountered: