Skip to content

Instantly share code, notes, and snippets.

@droid-it
Last active Sep 28, 2021
Embed
What would you like to do?
@Composable
fun TimerScreen() {
LaunchedEffect(key1 = Unit, block = {
try {
startTimer(5000L) { // start a timer for 5 secs
println("Timer ended")
}
} catch(ex: Exception) {
println("timer cancelled")
}
})
}
suspend fun startTimer(time: Long, onTimerEnd: () -> Unit) {
delay(timeMillis = time)
onTimerEnd()
}
@hoaithuonghg
Copy link

Hi,
How about the startTimer function will be implemented. I want to run the example. But I could not implement the function.

@droid-it
Copy link
Author

Hey, sorry for missing that piece out. You can refer to it in the updated gist above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment