Predicting server-side data #3616
-
Imagine I was writing an application that fetches how many units of a resource are currently available and its (static) hourly production via an API call. Knowing those numbers I'd like to predict the current value of resources every second without polling the server itself. This should be more or less deterministic until I receive a message, for example via a WebSocket, that something has changed. Since I want to reuse that amount of resources across different components I thought of the following implementation: First have a query that fetches a snapshot of the current amount of resources, its production and the timestamp of the snapshot. Then create a query similar to the example in the docs that has a refetch interval and does not fire an API call but instead updates the predicted amount of resources at the time of invocation. Any suggestions on whether there is even better solutions to that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
sounds good. just make sure to set |
Beta Was this translation helpful? Give feedback.
sounds good. just make sure to set
staleTime
high enough so that no additional refetches occur.