Replies: 2 comments
-
How would As a complete replacement it wouldn't work as we need to be able to have client side data fetching. As an alternative it would be pretty limited, how would it handle parallel data fetching with different re-fetching requirements? (see example below) Definitely open to alternatives though as long as it can retain all the functionality. export function routeData({
data,
location,
}: RouteDataArgs<typeof parentRouteData>) {
// refetch when ?page changes
const items = createServerData$(([_, page]) => fetchItems(page), {
key: () => ["items", location.query.page],
})
// fetch on navigation to this route only
const announcement = createServerData$(() => fetchAnnouncement(), {
key: "announcement",
})
// fetch with a dependency on the parent's routeData
const profile = createServerData$(
([_, accountId]) => fetchProfile(accountId),
{
key: () => ["profile", data.accountId()],
}
)
// client side fetch / server side fetch during ssr
const randomCat = createRouteData(
() => fetch("https://cataas.com/cat?json=true"),
{
key: "randomCat",
}
)
return { items, announcement, profile, randomCat }
} |
Beta Was this translation helpful? Give feedback.
-
I'm unsure about how routeData gets compiled into something that Node can execute to implement
I understand that SERVER_DATA would not completely replace routeData, as routeData is also used for client-side code. However, I think it is easy to comprehend SERVER_DATA's approach, as it functions similarly to GET/POST/DELETE API methods.
Regarding how it handles parallel data fetching with different re-fetching requirements, thank you for providing a comprehensive example. I haven't done anything complex yet, but based on the Solid Start examples, it seems that most cases can be covered by a single server data fetch. I don't think this would be limiting, as it seems similar to SvelteKit's PS all of this reasoning is based on an assumption that |
Beta Was this translation helpful? Give feedback.
-
Currently passing server data gives
public static void main String[] System.out.println
vibes. It also get lost between similar looking methods when you scan a file quickly to understand what it's doing with-auth example:I'd like to suggest a simpler approach which is aligned with other API routes patterns:
Type checking works fine for me with a following helper function:
*but it should be possible to be lifted into a library with a bit of type inference magic
It may also requires tweaking start/fs-router/router.js:
Please let me know if you find these suggestions feasible. I personally think that it makes onboarding for new people(like myself) way easier because they don't have to copy all of these boilerplate and learn about optional parameters and tags.
Beta Was this translation helpful? Give feedback.
All reactions