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

Function run

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

Source from the content-addressed store, hash-verified

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

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