Skip to content

Commit 563de6e

Browse files
committed
Reorder callbacks
1 parent 83a8028 commit 563de6e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/kotlin/com/tinder/StateMachine.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ class StateMachine<STATE : Any, EVENT : Any, SIDE_EFFECT : Any> private construc
1212
get() = stateRef.get()
1313

1414
fun transition(event: EVENT): Transition<STATE, EVENT, SIDE_EFFECT> {
15-
val transition = synchronized(stateRef) {
15+
val transition = synchronized(this) {
1616
val fromState = stateRef.get()
1717
val transition = fromState.getTransition(event)
1818
if (transition is Transition.Valid) {
1919
stateRef.set(transition.toState)
2020
}
2121
transition
2222
}
23+
transition.notifyOnTransition()
2324
if (transition is Transition.Valid) {
2425
with(transition) {
2526
with(fromState) {
@@ -30,7 +31,6 @@ class StateMachine<STATE : Any, EVENT : Any, SIDE_EFFECT : Any> private construc
3031
}
3132
}
3233
}
33-
transition.notifyOnTransition()
3434
return transition
3535
}
3636

0 commit comments

Comments
 (0)