Skip to content

Instantly share code, notes, and snippets.

@GianpaMX
Created August 26, 2020 18:21
Show Gist options
  • Save GianpaMX/3ae6381464f47fddfb31c4288ce2c0ce to your computer and use it in GitHub Desktop.
Save GianpaMX/3ae6381464f47fddfb31c4288ce2c0ce to your computer and use it in GitHub Desktop.
operator fun invoke(): Flow<State> = timeApi
.ticker()
.combine(transitionApi.observeTransitionLog()) { now, transition ->
transition.toState(now)
}
.distinctUntilChanged()
.onEach {
try {
if (it is State.Pomodoro) turnOnZenMode() else turnOffZenMode()
} catch (e: Exception) {
errorChannel.send(e)
}
}
.onEach {
if (it is State.Pomodoro || it is State.Break) it.doOnTimeUp {
nextState(Action.COMPLETE)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment