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

Method constructor

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected