-
Notifications
You must be signed in to change notification settings - Fork 239
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
Web app features > Fetch data > Svelte #183
Comments
In reality though, we wouldn't encourage that code either, but to use SvelteKit: https://kit.svelte.dev/docs/load The "Router link" and "Routing" examples demonstrate using SvelteKit. I think this one probably should too for consistency and to follow best practices |
Any plans adding sveltekit snippets instead of svelte? I was hoping to get some more examples from here for sveltekit fetching data. Or if this site might not be the place for this type of snippets, i'd love to hear from the community on how they handle these cases or resource to use. |
If we include meta frameworks, it would be too much work to maintain it across all frameworks. The documentation of meta frameworks is the place to go. |
Going back to the original discussion then. @matschik said in #186 (comment):
I suppose it helps for comparing frameworks if they're written in the same style, but at the same time the code as it's written now doesn't seem how you'd write it idiomatically in Svelte to me. I don't know if I've ever seen anyone use stores to track fetch state in this manner before in Svelte. I'm not super familiar with TanStack query or why they made the design choices they did. I believe that library also supports React and so my naive guess would be that it was written that way to mirror the React version rather than because it's how someone really familiar with Svelte would write it. I'd be curious to hear the reason why you say |
The main reason is to have a better experience when comparing Svelte fetch data snippet with others frameworks. In short, this snippet is for client data fetching only, and the best way to handle client data fetching state I know is a pattern similar to And for Svelte 5, it's an opportunity to show one of the main reason Svelte 5 was made: more simple reusable code. |
A quick glance at the snippets from other frameworks show that some of them only use 1 file. |
I think the argument from @GauBen still stands: if at some point we develop a "fetch" method for the frontend part, I would also recommend using the If at some point this project starts showcasing different methods for meta frameworks, especially when it's about backend code, then it's an entirely new category of study. It may not fit on the project at all (because it's... well... backend and not frontend?). But even then, for synchronization purposes, one may at some point need to fetch data from the client anyway, so a clean |
Hey!
I feel like the current "Fetch data" snippet does not do Svelte justice as there is a special
{#await}
tag for that matter. The whole snippet can be shortened to:I will open a PR if this change is accepted
The text was updated successfully, but these errors were encountered: