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

Method constructor

packages/query-core/src/onlineManager.ts:21–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected