MCPcopy Create free account
hub / github.com/SvelteStack/svelte-query / removeObserver

Method removeObserver

src/queryCore/core/query.ts:339–363  ·  view source on GitHub ↗
(observer: QueryObserver<any, any, any, any, any>)

Source from the content-addressed store, hash-verified

337 }
338
339 removeObserver(observer: QueryObserver<any, any, any, any, any>): void {
340 if (this.observers.indexOf(observer) !== -1) {
341 this.observers = this.observers.filter(x => x !== observer)
342
343 if (!this.observers.length) {
344 // If the transport layer does not support cancellation
345 // we'll let the query continue so the result can be cached
346 if (this.retryer) {
347 if (this.retryer.isTransportCancelable || this.abortSignalConsumed) {
348 this.retryer.cancel({ revert: true })
349 } else {
350 this.retryer.cancelRetry()
351 }
352 }
353
354 if (this.cacheTime) {
355 this.scheduleGc()
356 } else {
357 this.cache.remove(this)
358 }
359 }
360
361 this.cache.notify({ type: 'observerRemoved', query: this, observer })
362 }
363 }
364
365 getObserversCount(): number {
366 return this.observers.length

Callers 4

destroyMethod · 0.45
updateQueryMethod · 0.45
onUnsubscribeMethod · 0.45
mutateMethod · 0.45

Calls 4

scheduleGcMethod · 0.95
cancelMethod · 0.65
removeMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected