Skip to content

Commit 6c9e154

Browse files
fix(overmind): return result from transition callback
1 parent 364f93e commit 6c9e154

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/node_modules/overmind/src/statemachine.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ export class StateMachine<Base extends IState, States extends TStates, State ext
8282
Object.assign(this, newState)
8383
this.state = state
8484

85+
let result
8586
if (callback) {
86-
callback(this)
87+
result = callback(this)
8788
}
8889

8990
tree.blockMutations()
9091

92+
return result
9193
} else if (process.env.NODE_ENV === 'development' && state !== this.state) {
9294
console.warn(`Overmind Statemachine - You tried to transition into "${state}", but it is not a valid transition. The valid transitions are ${JSON.stringify(transitions[this.state])}`)
9395
} else if (process.env.NODE_ENV === 'development' && state === this.state) {

0 commit comments

Comments
 (0)