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

Method onSubscribe

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

Source from the content-addressed store, hash-verified

88 }
89
90 protected onSubscribe(): void {
91 if (this.listeners.size === 1) {
92 this.#currentQuery.addObserver(this)
93
94 if (shouldFetchOnMount(this.#currentQuery, this.options)) {
95 this.#executeFetch()
96 } else {
97 this.updateResult()
98 }
99
100 this.#updateTimers()
101 }
102 }
103
104 protected onUnsubscribe(): void {
105 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