MCPcopy Create free account
hub / github.com/TanStack/query / constructor

Method constructor

packages/query-core/src/focusManager.ts:15–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13 #setup: SetupFn
14
15 constructor() {
16 super()
17 this.#setup = (onFocus) => {
18 // addEventListener does not exist in React Native, but window does
19 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
20 if (typeof window !== 'undefined' && window.addEventListener) {
21 const listener = () => onFocus()
22 // Listen to visibilitychange
23 window.addEventListener('visibilitychange', listener, false)
24
25 return () => {
26 // Be sure to unsubscribe if a new handler is set
27 window.removeEventListener('visibilitychange', listener)
28 }
29 }
30 return
31 }
32 }
33
34 protected onSubscribe(): void {
35 if (!this.#cleanup) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected