-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
fix set store value ssr #5419
fix set store value ssr #5419
Conversation
wow, the 2 issues seems hard, especially, it is modifying the store directly via 1 alternative i can think of it is to subscribe to the store early on, which the listener can keep updating what do you think? |
I think having a subscription to the store throughout the SSR'd component that gets unsubscribed at the end makes sense. It does sound like that would help with those other issues - and if we can align what the SSR component does more closely with what the browser component does, that sounds like a good idea. |
probably im gonna change the implementation of this PR / start a new PR that does "having a subscription to the store throughout the SSR'd component that gets unsubscribed at the end" that would theoratically solve most of the ssr + svelte store issues. #3375's suboptimal code is because, svelte store value can be changed throughout the main code, via again, if we change the store mechanism in ssr, having a subscription, we can probably remove that part of the code too. |
I'm marking this as draft. If you'd prefer to rework SSR store subscription in a separate PR, this can be closed. |
@@ -0,0 +1,3 @@ | |||
export default { | |||
html: `{"answer":4}` |
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.
can you rebase against master and make sure npm run lint
passes? we just updated our eslint config to allow only single quotes
Other than the linting problems described above, is there anything else preventing this PR from being merged? I'd be happy to rebase and fix the lint errors if it'll help get this merged. |
@arackaf there's some edge cases that this MR didn't manage to fix as mentioned in #5419 (comment), I'll probably relook again soon |
@tanhauhau if you're still planning on taking a closer look to solve those other edge cases then cool, I'll leave you to it. But if you decide to move on, I'd be more than happy to help get this incomplete solution in, since, iiuc, it does solve some problems. |
any change this could be merged? My use case would be fixed with this and I suspect many other people would benefit from this early implementation If there are any edge cases not covered, could they not be treated as an improvement to work on in a different PR? |
7c9b31b
to
bde5f93
Compare
Closes #3375
Have to instrument setting store variable,
store
to sync up the dollar-prefixed variable,$store
to simulate the same behavior in DOM.An alternative would be to subscribe to store at the early of the component, and make sure to unsubscribe them right before rendering them.
Before submitting the PR, please make sure you do the following
Tests
npm test
and lint the project withnpm run lint