How can I create a component for wrapping the loading states?
* A "typed" component that is 🙂
I'm using @tanstack/svelte-query@5.0.0-rc12
I have a bunch of admin panels, that are each backed by individual queries. Ideally I want to have the loading/failure states all have the same code - without boilerplate.
I'd love to be able to pass the data as a property to the slot. These are my current results - which is probably serviceable, ill, just have expose the query itself rather than the data.
Any ideas? I'm reasonable at generics and svelte, but not sure if I'm being stupid, or svelte has a limitation here (my fetchFns have typed return values from zod).
GenericsExample.svelte
+page.svelte
Also, assigning data using
$: data = $query.data
also results in undefined. Runtime seems to be ok tho.2 Replies
foreign-sapphireOP•2y ago
FWIW, I've decided against this approach.
Now it will be
This still allows for typesafety where I need it, and the panels become more composable.
wise-white•2y ago
Looks good!