Skip to Content
Effetch Query
The client

Focus and online signals

Choose what tells a client the app is focused and online.

Queries in use refetch when the app regains focus or the device comes back online, if they're stale (refetchOnFocus and refetchOnReconnect). The signals option tells the client when those happen. There are three choices:

  • Signals.browser, the default: focus is the page becoming visible again, and online follows navigator.onLine. Without a DOM, such as on a server or in React Native, it never changes.
  • Signals.none: never changes, so no query refetches on focus or reconnect. Use it for a script or a test with no focus or network events.
  • reactNativeSignals from @monarcode/effetch-query/react-native, built from React Native's AppState and NetInfo, as React Native shows.

For another platform, write your own Signals.Signals from two atoms. focus is a number that changes each time the app regains focus: only the change counts, not the value. online is a boolean, where going from false to true is a reconnect.