Skip to content

Instantly share code, notes, and snippets.

@droid-it
Created September 29, 2021 07:52
Show Gist options
  • Save droid-it/d1c410b741157284892f896e6616e5a2 to your computer and use it in GitHub Desktop.
Save droid-it/d1c410b741157284892f896e6616e5a2 to your computer and use it in GitHub Desktop.
@Composable
fun Timer() {
val timerDuration = 5000L
println("Composing Timer")
LaunchedEffect(key1 = Unit, block = {
startTimer(timerDuration) {
println("Timer ended")
}
})
}
suspend fun startTimer(time: Long, onTimerEnd: () -> Unit) {
delay(timeMillis = time)
onTimerEnd()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment