-
-
Save GuilhE/0c979cd8ccedd2adc349b94059929d71 to your computer and use it in GitHub Desktop.
Medium articles - MVI+FSM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
StateMachine.create<TimerState.State, TimerState.Event, TimerState.SideEffect> { | |
initialState(TimerState.State.Idle) | |
state<TimerState.State.Idle> { | |
on<TimerState.Event.OnSetTimer> { | |
transitionTo(TimerState.State.SettingTimer, TimerState.SideEffect.SetTimer) | |
} | |
} | |
state<TimerState.State.SettingTimer> { | |
on<TimerState.Event.OnTimerSet> { | |
transitionTo(TimerState.State.Idle, TimerState.SideEffect.TimerReady(it.value)) | |
} | |
} | |
onTransition { | |
val validTransition = it as? StateMachine.Transition.Valid ?: return@onTransition | |
//emit ui state changes | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment