Skip to content

Commit ac2cab9

Browse files
feat(overmind): split up running action and setting new transition state
1 parent fa0af0d commit ac2cab9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/node_modules/overmind/src/config/statechart.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,15 @@ export function statechart<C extends IConfiguration, S extends string>(
188188
filter(function canTransition(_, { transition }) {
189189
return Boolean(transition)
190190
}),
191-
mutate(function changeState(context: any, { transition, payload }) {
191+
mutate(function runAction(context: any, { transition, payload }) {
192192
if (transition === 'entry' || transition === 'exit') {
193193
actions[key](context, payload)
194194
return
195195
}
196196

197+
actions[key](context, payload)
198+
}),
199+
mutate(function performTransition(context: any) {
197200
const stateTarget = getTarget(
198201
context.state,
199202
context.execution.namespacePath
@@ -206,8 +209,6 @@ export function statechart<C extends IConfiguration, S extends string>(
206209
const currentStatePath = stateTarget.state.slice()
207210
const stateTransitions = currentStatePath.map(() => null)
208211

209-
actions[key](context, payload)
210-
211212
// Build new transition path
212213
while (currentStatePath.length) {
213214
const target = getStateTarget(chart, currentStatePath)

0 commit comments

Comments
 (0)