(
options: QueryObserverOptions<
TQueryFnData,
TError,
TData,
TQueryData,
TQueryKey
>,
)
| 136 | } |
| 137 | |
| 138 | setOptions( |
| 139 | options: QueryObserverOptions< |
| 140 | TQueryFnData, |
| 141 | TError, |
| 142 | TData, |
| 143 | TQueryData, |
| 144 | TQueryKey |
| 145 | >, |
| 146 | ): void { |
| 147 | const prevOptions = this.options |
| 148 | const prevQuery = this.#currentQuery |
| 149 | |
| 150 | this.options = this.#client.defaultQueryOptions(options) |
| 151 | |
| 152 | if ( |
| 153 | this.options.enabled !== undefined && |
| 154 | typeof this.options.enabled !== 'boolean' && |
| 155 | typeof this.options.enabled !== 'function' && |
| 156 | typeof resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== |
| 157 | 'boolean' |
| 158 | ) { |
| 159 | throw new Error( |
| 160 | 'Expected enabled to be a boolean or a callback that returns a boolean', |
| 161 | ) |
| 162 | } |
| 163 | |
| 164 | this.#updateQuery() |
| 165 | this.#currentQuery.setOptions(this.options) |
| 166 | |
| 167 | if ( |
| 168 | prevOptions._defaulted && |
| 169 | !shallowEqualObjects(this.options, prevOptions) |
| 170 | ) { |
| 171 | this.#client.getQueryCache().notify({ |
| 172 | type: 'observerOptionsUpdated', |
| 173 | query: this.#currentQuery, |
| 174 | observer: this, |
| 175 | }) |
| 176 | } |
| 177 | |
| 178 | const mounted = this.hasListeners() |
| 179 | |
| 180 | // Fetch if there are subscribers |
| 181 | if ( |
| 182 | mounted && |
| 183 | shouldFetchOptionally( |
| 184 | this.#currentQuery, |
| 185 | prevQuery, |
| 186 | this.options, |
| 187 | prevOptions, |
| 188 | ) |
| 189 | ) { |
| 190 | this.#executeFetch() |
| 191 | } |
| 192 | |
| 193 | // Update result |
| 194 | this.updateResult() |
| 195 |
no test coverage detected