-
-
Notifications
You must be signed in to change notification settings - Fork 2
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/361 bug singleton server side stores used for email verification status #363
Bug/361 bug singleton server side stores used for email verification status #363
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the context functions introduce a race condition. Combined with the fact that making the expression reactive does nothing (svelte can't detect the change).
If user page is executed first, then it'll get a null value instead of the store, then the Layout file gets executed putting the store in the context, but at this point the page has no reason to execute useEmailResult again. I'd say make a defineStoreContext
that sets a value in the context when use is called and the context returns null. Basically make it init automatically from the first place it's called.
@hahn-kev I don't think I've introduced a race condition. Also, having the context auto-init on first use wouldn't work, because context is scoped to the children of the component that initializes it, so it needs to be the layout in this case. I can't find it documented, but I think the order in which layouts and pages/components are initialized is consistent, starting at the root layout and going down. So, if a parent component initializes/sets context, it is ready and available when a child component initializes. The tutorial makes that assumption: https://learn.svelte.dev/tutorial/context-api. I think, that if you want context to be reactive, you should make the context value a store and let the store handle the reactivity. |
ok, I see now, I didn't realize that Layout used EmailVerificationStatus. This does mean that the EmailVerificationStatus component is only usable from Layout.svelte or a child of Layout.svelte, otherwise it may or may not work depending on the rendering order. But I guess that's ok since this is used in the root of the app, so all pages should apply. |
Resolves #361
Introduces a simple layer on top of the context-api and uses that to: