Skip to content

Instantly share code, notes, and snippets.

@Laimiux
Last active September 25, 2019 21:30
Show Gist options
  • Save Laimiux/dbcc0762af6793ba6c1bdffdeadc7c3a to your computer and use it in GitHub Desktop.
Save Laimiux/dbcc0762af6793ba6c1bdffdeadc7c3a to your computer and use it in GitHub Desktop.
fun startStopButton(state: State, context: FormulaContext<State>): ButtonRenderModel {
return if (state.isRunning) {
ButtonRenderModel(
text = "Stop",
onSelected = context.callback {
transition(state.copy(isRunning = false))
}
)
} else {
ButtonRenderModel(
text = "Start",
onSelected = context.callback {
transition(state.copy(isRunning = true))
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment