Skip to content

Instantly share code, notes, and snippets.

@Laimiux
Last active September 25, 2019 22:32
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/46bfa060108ebb25a6cea33b84d5f0a8 to your computer and use it in GitHub Desktop.
Save Laimiux/46bfa060108ebb25a6cea33b84d5f0a8 to your computer and use it in GitHub Desktop.
override fun evaluate(
input: Unit,
state: State,
context: FormulaContext<State>
): Evaluation<StopwatchRenderModel> {
return Evaluation(
renderModel = ...,
updates = context.updates {
if (state.isRunning) {
val incrementTimePassedEvents = RxStream.fromObservable {
Observable
.interval(1, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
}
events(incrementTimePassedEvents) {
transition(state.copy(
timePassedInMillis = state.timePassedInMillis + 1
))
}
}
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment