lit-query: controller render method #10711
Replies: 1 comment
-
|
This seems reasonable as a thin convenience layer, especially because Lit's I would keep it as a small adapter helper over the existing query result shape rather than changing the query state model. Something like: repo.render({
pending: () => html`Loading...`,
error: (query) => html`Error: ${query.error.message}`,
success: (query) => html`${query.data.name}`,
})would mostly be sugar for: if (repo.result.isPending) return pending()
if (repo.result.isError) return error(repo.result)
return success(repo.result)The caveat is naming. TanStack Query normally uses For tests, avoiding full Lit rendering may be intentional: the controller can be tested as state behavior without pulling in DOM/render assertions. A good PR shape might be:
As a proof of concept, this could even start as a userland helper. If it feels natural, moving it into the Lit adapter makes sense. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The Lit Tasks API includes a
rendermethod which simplifies rendering based on task status:It would be nice for consistency if the query controllers did the same:
It seems fairly simple to implement, so I'm happy to open a PR if this is wanted. (I don't particularly understand the tests though, it seems like they intentionally avoid using
lititself for some reason)Beta Was this translation helpful? Give feedback.
All reactions