@internal
(observer: QueryObserver<any, any, any, any, any>)
| 521 | |
| 522 | /** @internal */ |
| 523 | removeObserver(observer: QueryObserver<any, any, any, any, any>): void { |
| 524 | const index = this.observers.indexOf(observer) |
| 525 | if (index !== -1) { |
| 526 | this.observers.splice(index, 1) |
| 527 | |
| 528 | if (!this.observers.length) { |
| 529 | // If the transport layer does not support cancellation |
| 530 | // we'll let the query continue so the result can be cached |
| 531 | if (this.#retryer) { |
| 532 | if ( |
| 533 | this.#abortSignalConsumed || |
| 534 | (this.state.fetchStatus === 'paused' && |
| 535 | this.state.status === 'pending') |
| 536 | ) { |
| 537 | this.#retryer.cancel({ revert: true }) |
| 538 | } else { |
| 539 | this.#retryer.cancelRetry() |
| 540 | } |
| 541 | } |
| 542 | |
| 543 | this.scheduleGc() |
| 544 | } |
| 545 | |
| 546 | this.#cache.notify({ type: 'observerRemoved', query: this, observer }) |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | /** |
| 551 | * Returns the number of observers currently subscribed to this query. |
no test coverage detected