Skip to content

Commit 6ccdf64

Browse files
fix(overmind): fix reset of statemachine
1 parent 93cf452 commit 6ccdf64

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/node_modules/overmind/src/statemachine.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ export type Statemachine<States extends string> = {
1515
}
1616

1717
const CURRENT_EXIT = Symbol('CURRENT_EXIT')
18+
const INITIAL_STATE = Symbol('INITIAL_STATE')
1819

1920
class StateMachine<States extends string> {
2021
current: States
2122
private [CURRENT_EXIT]: (() => void) | undefined
23+
private [INITIAL_STATE]: States
2224
constructor(definition: StatemachineDefinition<States>) {
25+
this[INITIAL_STATE] = definition.initial
2326
this.current = definition.initial
2427

2528
Object.keys(definition.states).reduce((aggr, key) => {
@@ -47,6 +50,7 @@ class StateMachine<States extends string> {
4750
exit()
4851
this[VALUE][CURRENT_EXIT] = undefined
4952
}
53+
this.current = this[INITIAL_STATE]
5054
}
5155
}
5256

0 commit comments

Comments
 (0)