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

Method removeObserver

packages/query-core/src/query.ts:362–383  ·  view source on GitHub ↗
(observer: QueryObserver<any, any, any, any, any>)

Source from the content-addressed store, hash-verified

360 }
361
362 removeObserver(observer: QueryObserver<any, any, any, any, any>): void {
363 const index = this.observers.indexOf(observer)
364 if (index !== -1) {
365 this.observers.splice(index, 1)
366
367 if (!this.observers.length) {
368 // If the transport layer does not support cancellation
369 // we'll let the query continue so the result can be cached
370 if (this.#retryer) {
371 if (this.#abortSignalConsumed || this.#isInitialPausedFetch()) {
372 this.#retryer.cancel({ revert: true })
373 } else {
374 this.#retryer.cancelRetry()
375 }
376 }
377
378 this.scheduleGc()
379 }
380
381 this.#cache.notify({ type: 'observerRemoved', query: this, observer })
382 }
383 }
384
385 getObserversCount(): number {
386 return this.observers.length

Callers 6

destroyMethod · 0.45
#updateQueryMethod · 0.45
onUnsubscribeMethod · 0.45
resetMethod · 0.45
mutateMethod · 0.45
query.test.tsxFile · 0.45

Calls 3

#isInitialPausedFetchMethod · 0.95
cancelMethod · 0.80
notifyMethod · 0.45

Tested by

no test coverage detected