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

Function hostConnected

packages/lit-query/src/controllers/BaseController.ts:42–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 }
41
42 hostConnected(): void {
43 if (this.connected || this.destroyed) {
44 return
45 }
46
47 this.connected = true
48 let contextResolutionAttempt: number | undefined
49
50 if (this.explicitClient) {
51 this.queryClientResolutionState = 'bound'
52 } else {
53 contextResolutionAttempt = ++this.connectionAttempt
54 this.beginContextResolution()
55 }
56
57 // Defer onConnected to ensure subclass constructors complete before
58 // lifecycle callbacks access subclass state. This handles the case where
59 // addController is called on an already-connected host (e.g., during
60 // willUpdate), which synchronously triggers hostConnected before
61 // subclass field initialization.
62 queueMicrotask(() => {
63 if (this.connected && !this.destroyed) {
64 this.onConnected()
65 }
66 })
67
68 if (contextResolutionAttempt !== undefined) {
69 // Provider-backed controllers on already-connected hosts should finish
70 // their deferred onConnected pass before a context client binds.
71 this.queueContextResolution(contextResolutionAttempt)
72 }
73 }
74
75 hostDisconnected(): void {
76 if (!this.connected) {

Callers

nothing calls this directly

Calls 1

onConnectedMethod · 0.45

Tested by

no test coverage detected