@internal
(mutation: Mutation<any, any, any, any>)
| 193 | |
| 194 | /** @internal */ |
| 195 | canRun(mutation: Mutation<any, any, any, any>): boolean { |
| 196 | const scope = scopeFor(mutation) |
| 197 | if (typeof scope === 'string') { |
| 198 | const mutationsWithSameScope = this.#scopes.get(scope) |
| 199 | const firstPendingMutation = mutationsWithSameScope?.find( |
| 200 | (m) => m.state.status === 'pending', |
| 201 | ) |
| 202 | // we can run if there is no current pending mutation (start use-case) |
| 203 | // or if WE are the first pending mutation (continue use-case) |
| 204 | return !firstPendingMutation || firstPendingMutation === mutation |
| 205 | } else { |
| 206 | // For unscoped mutations there are never any pending mutations in front of the |
| 207 | // current mutation |
| 208 | return true |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /** @internal */ |
| 213 | runNext(mutation: Mutation<any, any, any, any>): Promise<unknown> { |