Replies: 1 comment
-
It looks like there were some efforts around making a Lit adapter for TanStack query. TanStack/query#6390 I haven't looked at any implementations or the video linked in that discussion yet so I can't comment on the quality. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here is my case.
I need to surface messages in different pages of a big website. And I plan to use lit element to generate a local element <my-element> and used it in different pages. In this element, we need a API call to fetch data from our backend, code like below:
But in some pages, the message need to be surfaced in each row of table like below
<my-element id=id1 />
<my-element id=id2 />
<my-element id=id3 />
In this way, each lit element will call backend
https://myendpoint/message?id=' +id
to get the message, this is time consuming.So assume the backend API
https://myendpoint/message
can fetch all messages belongs to this page in one request, is there any way that we can render above table with only one API call tohttps://myendpoint/message
?My idea is to leverage ReactQuery cache to cache the API response and filter it by
id
. Then if one API call in<my-element id=id1 />
is completed and the result will be cached, other API call in lit element like<my-element id=id2 />
will directly get response from react cache and there won't be a real network request.Can somebody here help to confirm if my solution will work? If not, any guidance?
Beta Was this translation helpful? Give feedback.
All reactions