Skip to content

Resolve "Improve data refresh"

Mael Gaonach requested to merge 207-improve-data-refresh into main

Closes #207 (closed)

This implements the following rules:

If endpoint is set as autoRefresh: true (set in endpoint definition):

  • If browser tab is active and in the foreground: data will be refreshed every autoRefreshIntervalMinutes minutes (set in endpoint definition)
  • If browser tab is not active or in the background: data will be refreshed when user comes back to the app if last refresh was more than autoRefreshIntervalMinutes minutes ago

If endpoint is set as autoRefresh: false (set in endpoint definition):

  • data will never be refresh if newer than 20 minutes
  • data will be refreshed if older than 20 minutes and a new component loads it or the app comes back into focus

autoRefreshIntervalMinutes value

In each endpoint's definition, when autoRefresh is set to true, autoRefreshIntervalMinutes can be set to:

  • a number
  • a funtion taking the fetched data and the parameters in agruments and returnning a number

Override for a specific call

This is applied to every call of the endpoint with useGetEndpoint but a parameter options.refreshIntervalMinutes can be given to any call of useGetEndpoint to override this behavior for this specific call.

Edited by Mael Gaonach

Merge request reports

Loading