T
TanStack2w ago
like-gold

Taking params via quercollection options

Is there a best way to do this or am i thinking about this wrong? for context, i want to make a collection for session messages, on updates i'll probably end up using your writeBatch function to avoid refetches. however how would i go about the queryfn in an approach like this? sorry if this is a newbie type of question, i usually like deep diving on docs but they aren't there yet and im sure we've got some pros in here
10 Replies
like-gold
like-goldOP2w ago
@samwillis tagging for visibility since we spoke ab this earlier my immediate kind of thought here would be to make some sort of collection factory hehe
extended-salmon
extended-salmon2w ago
a factory function is a good way to do this
like-gold
like-goldOP2w ago
that was a LOT easier than i expected wow tanstack always a pleasure to work with
like-gold
like-goldOP6d ago
Here is my factory function
No description
like-gold
like-goldOP6d ago
here is how i am handling events
like-gold
like-goldOP6d ago
No description
like-gold
like-goldOP6d ago
the problem i am having is that these events are getting streamed in pretty fast (they are AI message streams) and the UI isn't really updating fast enough should i be debouncing this or something or is there something that i am missing
like-gold
like-goldOP6d ago
i have a feeling that it is because i am storing a message with parts:
No description
like-gold
like-goldOP6d ago
and i am updating the array in an object instead of directly updating something like a string i guess my main question is, is it an issue with my data structure, or does tanstack Db batch rapid updates? @samwillis
extended-salmon
extended-salmon6d ago
We don't batch/throttle updates, if the ui can't keep up with the changes then throttling at the ui layer is likely best. The alternative is to concatenate the tokens inside you api when writing to Postgres, or insert them inside a single transaction per time slide (the sync runs transactionally, you shouldn't see the ui update with part of a transaction).

Did you find this page helpful?