-
-
Save droid-it/e4aa27cfb3afd001415fcb94567e3bba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, sorry for missing that piece out. You can refer to it in the updated gist above