Skip to content

Instantly share code, notes, and snippets.

@Laimiux
Created September 25, 2019 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Laimiux/a09350babafd0ad88f6a986566d43812 to your computer and use it in GitHub Desktop.
Save Laimiux/a09350babafd0ad88f6a986566d43812 to your computer and use it in GitHub Desktop.
class StopwatchFormula : Formula<Unit, StopwatchFormula.State, StopwatchRenderModel> {
// We will use this a little later.
object State
override fun initialState(input: Unit): State = State
override fun evaluate(
input: Unit,
state: State,
context: FormulaContext<State>
): Evaluation<StopwatchRenderModel> {
return Evaluation(
renderModel = StopwatchRenderModel(
timePassed = "5s 10",
startStopButton = ButtonRenderModel(
text = "Start",
onSelected = { /* TODO */ }
),
resetButton = ButtonRenderModel(
text = "Reset",
onSelected = { /* TODO */ }
)
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment