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

Method onSubscribe

packages/query-core/src/queryObserver.ts:113–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111 }
112
113 protected override onSubscribe(): void {
114 if (this.listeners.size === 1) {
115 this.#currentQuery.addObserver(this)
116
117 if (shouldFetchOnMount(this.#currentQuery, this.options)) {
118 this.#executeFetch()
119 } else {
120 this.updateResult()
121 }
122
123 this.#updateTimers()
124 }
125 }
126
127 protected override onUnsubscribe(): void {
128 if (!this.hasListeners()) {

Callers

nothing calls this directly

Calls 5

#executeFetchMethod · 0.95
updateResultMethod · 0.95
#updateTimersMethod · 0.95
shouldFetchOnMountFunction · 0.85
addObserverMethod · 0.45

Tested by

no test coverage detected