MCPcopy
hub / github.com/TanStack/query / removeObserver

Method removeObserver

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

Source from the content-addressed store, hash-verified

353 }
354
355 removeObserver(observer: QueryObserver<any, any, any, any, any>): void {
356 if (this.observers.includes(observer)) {
357 this.observers = this.observers.filter((x) => x !== observer)
358
359 if (!this.observers.length) {
360 // If the transport layer does not support cancellation
361 // we'll let the query continue so the result can be cached
362 if (this.#retryer) {
363 if (this.#abortSignalConsumed) {
364 this.#retryer.cancel({ revert: true })
365 } else {
366 this.#retryer.cancelRetry()
367 }
368 }
369
370 this.scheduleGc()
371 }
372
373 this.#cache.notify({ type: 'observerRemoved', query: this, observer })
374 }
375 }
376
377 getObserversCount(): number {
378 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 2

cancelMethod · 0.80
notifyMethod · 0.45

Tested by

no test coverage detected