* Subscribes an observer to the query and stops its garbage collection. * @internal * @param observer - The observer to add. Adding an observer that is already subscribed does * nothing.
(observer: QueryObserver<any, any, any, any, any>)
| 616 | * nothing. |
| 617 | */ |
| 618 | addObserver(observer: QueryObserver<any, any, any, any, any>): void { |
| 619 | if (!this.observers.includes(observer)) { |
| 620 | this.observers.push(observer) |
| 621 | |
| 622 | // Stop the query from being garbage collected |
| 623 | this.clearGcTimeout() |
| 624 | |
| 625 | this.#cache.notify({ type: 'observerAdded', query: this, observer }) |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | /** |
| 630 | * Unsubscribes an observer from the query. |
no test coverage detected