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