()
| 229 | // noop |
| 230 | } |
| 231 | const run = () => { |
| 232 | // Apply the latest options before resolving `enabled`, so a query callback sees the current query. |
| 233 | // fix #6133 |
| 234 | observer.setOptions(defaultedOptions.value) |
| 235 | const { enabled } = defaultedOptions.value |
| 236 | if ( |
| 237 | (typeof enabled === 'function' |
| 238 | ? enabled(observer.getCurrentQuery()) |
| 239 | : enabled) !== false |
| 240 | ) { |
| 241 | const optimisticResult = observer.getOptimisticResult( |
| 242 | defaultedOptions.value, |
| 243 | ) |
| 244 | if (optimisticResult.isStale) { |
| 245 | stopWatch() |
| 246 | observer |
| 247 | .fetchOptimistic(defaultedOptions.value) |
| 248 | .then(resolve, (error: TError) => { |
| 249 | if ( |
| 250 | shouldThrowError(defaultedOptions.value.throwOnError, [ |
| 251 | error, |
| 252 | observer.getCurrentQuery(), |
| 253 | ]) |
| 254 | ) { |
| 255 | reject(error) |
| 256 | } else { |
| 257 | resolve(observer.getCurrentResult()) |
| 258 | } |
| 259 | }) |
| 260 | } else { |
| 261 | stopWatch() |
| 262 | resolve(optimisticResult) |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | run() |
| 268 |
no test coverage detected