MCPcopy Create free account
hub / github.com/TanStack/query / run

Function run

packages/vue-query/src/useBaseQuery.ts:166–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164 // noop
165 }
166 const run = () => {
167 if (defaultedOptions.value.enabled !== false) {
168 // fix #6133
169 observer.setOptions(defaultedOptions.value)
170 const optimisticResult = observer.getOptimisticResult(
171 defaultedOptions.value,
172 )
173 if (optimisticResult.isStale) {
174 stopWatch()
175 observer
176 .fetchOptimistic(defaultedOptions.value)
177 .then(resolve, (error: TError) => {
178 if (
179 shouldThrowError(defaultedOptions.value.throwOnError, [
180 error,
181 observer.getCurrentQuery(),
182 ])
183 ) {
184 reject(error)
185 } else {
186 resolve(observer.getCurrentResult())
187 }
188 })
189 } else {
190 stopWatch()
191 resolve(optimisticResult)
192 }
193 }
194 }
195
196 run()
197

Callers 1

suspenseFunction · 0.70

Calls 9

shouldThrowErrorFunction · 0.90
stopWatchFunction · 0.85
rejectFunction · 0.85
resolveFunction · 0.85
fetchOptimisticMethod · 0.80
getCurrentQueryMethod · 0.80
setOptionsMethod · 0.45
getOptimisticResultMethod · 0.45
getCurrentResultMethod · 0.45

Tested by

no test coverage detected