Skip to content
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

Svelte 5: add examples of mixing runes and store to documention #11668

Closed
mheinzerling opened this issue May 17, 2024 · 4 comments
Closed

Svelte 5: add examples of mixing runes and store to documention #11668

mheinzerling opened this issue May 17, 2024 · 4 comments

Comments

@mheinzerling
Copy link

mheinzerling commented May 17, 2024

Describe the problem

In most cases, we will not be able to migrate to Svelte 5 and runes in one commit. But even migrating one Writeable to a $state might cause many dependent changes, e.g. in derived. The documentation is missing some hints, how to correctly map/link/convert between old stores and new runes.

I created a small REPL with some mixed use cases. What is missing the get the second button working correctly? (And this the other code 'best practice'?)

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACpVUS2-jMBD-KyOrByjtpsneSGC1t733sIdlFfGYJFbBRrYJjRD_fcfmkYa2Uvdixp7vMYMHOnbgJWoW_umYSCtkIftZ1-yBmUttN_qMpUHaa9mo3J7sdK54beJEAPCqlspAV6DiZywg1TCGz0YqfIBWcZNmJfZwULKCZNRbaZtO2DYRViaXQhuHRQLvIZp53trfLhD7ySy68fJmOrlCFNNyDxt_dCjRgDapsdp3Nlgou6M3yndj6G1IxRH9D2vFfcVfv1JLcFW59XT8fdoY-dZ2qDWAu1lpYE59TDzdZPsTLwoU18Y-8yDs0uK9zECeXb9Rxt53hp7X-raVT92nkls_EbvVPCS0yeJfsgVq8EjVmxOCRqqugKwxRgpIKcxPqThycXTpoQ9LaKV6oU6UwtyUlx-7VTYoFvxMfpcSo4QVXNdlegmPihdbuzwarOjE4GMuy6YSOoT101P9Ct_nZdivDyphbo6tYAy_p0sF6jXcrezhnO2uV9EvUjagcGxHirzk-UvUeX4UX0lB0McBNeBAA_dWZXPfRqPJNIhLIx3MkOvszaAZ9uxen6ff9-Du6D_Kd_gvVK6j7uYL-rDw5bz34LmxH0esNlwKf5epFQ3ZEk8YgucN_TeqBWF0Gp70o6pkwQ8cCxYa1WD_t_8HCc3hj-MEAAA=

Describe the proposed solution

Add best practice examples for partial migrations.

Importance

would make my life easier

@mheinzerling
Copy link
Author

Slightly related to #9287

@dummdidumm
Copy link
Member

writable_mixed relies on a store and a state variable, but it will only update when the store value changes, because that's how derived stores work. In general, if you're working with stores and derived stores, don't mix in state variables if you expect them to contribute to the stores updating.

I don't think we need to add this to the documentation, therefore closing this.

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@mheinzerling
Copy link
Author

@dummdidumm Maybe my sample is kind of artificial. I totally get the point to not to do it in new projects.

Nevertheless, this is of course an actual issue in my migration process. If I migrate a shared writeable to a state rune, I'm forces to update everything that is connected to this writeable in one go. I can't even build the dev server in between to verify the current changes.
Of course anybody could figure out at their own how to address this issue, or decide to reject the migration at all, but a helpful guide in the documentation with some patterns could be useful. If I got Rich right in his last talk, your are interested in moving all project to Svelte 5 and prevent a splitting of the ecosystem.

@dummdidumm
Copy link
Member

With "don't need to add this to the documentation" I meant that specific gotcha of using state inside a derived. We'll have documentation about how to migrate, including stores and examples etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants