()
| 621 | } |
| 622 | |
| 623 | updateResult(): void { |
| 624 | const prevResult = this.#currentResult as |
| 625 | | QueryObserverResult<TData, TError> |
| 626 | | undefined |
| 627 | |
| 628 | const nextResult = this.createResult(this.#currentQuery, this.options) |
| 629 | |
| 630 | this.#currentResultState = this.#currentQuery.state |
| 631 | this.#currentResultOptions = this.options |
| 632 | |
| 633 | if (this.#currentResultState.data !== undefined) { |
| 634 | this.#lastQueryWithDefinedData = this.#currentQuery |
| 635 | } |
| 636 | |
| 637 | // Only notify and update result if something has changed |
| 638 | if (shallowEqualObjects(nextResult, prevResult)) { |
| 639 | return |
| 640 | } |
| 641 | |
| 642 | this.#currentResult = nextResult |
| 643 | |
| 644 | const shouldNotifyListeners = (): boolean => { |
| 645 | if (!prevResult) { |
| 646 | return true |
| 647 | } |
| 648 | |
| 649 | const { notifyOnChangeProps } = this.options |
| 650 | const notifyOnChangePropsValue = |
| 651 | typeof notifyOnChangeProps === 'function' |
| 652 | ? notifyOnChangeProps() |
| 653 | : notifyOnChangeProps |
| 654 | |
| 655 | if ( |
| 656 | notifyOnChangePropsValue === 'all' || |
| 657 | (!notifyOnChangePropsValue && !this.#trackedProps.size) |
| 658 | ) { |
| 659 | return true |
| 660 | } |
| 661 | |
| 662 | const includedProps = new Set( |
| 663 | notifyOnChangePropsValue ?? this.#trackedProps, |
| 664 | ) |
| 665 | |
| 666 | if (this.options.throwOnError) { |
| 667 | includedProps.add('error') |
| 668 | } |
| 669 | |
| 670 | return Object.keys(this.#currentResult).some((key) => { |
| 671 | const typedKey = key as keyof QueryObserverResult |
| 672 | const changed = this.#currentResult[typedKey] !== prevResult[typedKey] |
| 673 | |
| 674 | return changed && includedProps.has(typedKey) |
| 675 | }) |
| 676 | } |
| 677 | |
| 678 | const notifyListeners = shouldNotifyListeners() |
| 679 | |
| 680 | notifyManager.batch(() => { |
no test coverage detected