TanStackT
TanStack3y ago
7 replies
comprehensive-tomato

Dynamic Data Fetching Challenges with Vue and Sockets

1. I've implemented a socket listener for when a new alert is received. Once I get a new alert, I update the alertId ref and expect the associated query (i.e., useGetAlert) to fetch the data based on this updated alertId.

However, it seems that the only way I'm able to see the updated data is by setting up a watch on the isSuccess ref from the useGetAlert function. Without this watcher, it appears as though the new data isn't fetched or updated.

Question 1:
Is there a more direct or recommended way to fetch and update the data without relying on a watch when the alertId ref updates?

----------------------------------------------------------------------------------------------------

2.I've added the enabled configuration with the intention to only run the query when alertId has a truthy value. However, it seems that this configuration isn't behaving as expected.

Question 2:
How can I properly configure the query to remain disabled when there's no alertId value, and only run when there is a valid alertId? The current setup doesn't seem to be working as intended.

@MrMentor
Screenshot_2023-10-01_at_15.02.24.png
Screenshot_2023-10-01_at_15.02.10.png
Was this page helpful?