MCPcopy
hub / github.com/TanStack/query / canRun

Method canRun

packages/query-core/src/mutationCache.ts:160–175  ·  view source on GitHub ↗
(mutation: Mutation<any, any, any, any>)

Source from the content-addressed store, hash-verified

158 }
159
160 canRun(mutation: Mutation<any, any, any, any>): boolean {
161 const scope = scopeFor(mutation)
162 if (typeof scope === 'string') {
163 const mutationsWithSameScope = this.#scopes.get(scope)
164 const firstPendingMutation = mutationsWithSameScope?.find(
165 (m) => m.state.status === 'pending',
166 )
167 // we can run if there is no current pending mutation (start use-case)
168 // or if WE are the first pending mutation (continue use-case)
169 return !firstPendingMutation || firstPendingMutation === mutation
170 } else {
171 // For unscoped mutations there are never any pending mutations in front of the
172 // current mutation
173 return true
174 }
175 }
176
177 runNext(mutation: Mutation<any, any, any, any>): Promise<unknown> {
178 const scope = scopeFor(mutation)

Callers 3

executeMethod · 0.80
canContinueFunction · 0.80
canStartFunction · 0.80

Calls 3

scopeForFunction · 0.85
getMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected