Created
January 22, 2023 11:32
-
-
Save devrath/dccc167a98a9f3879ac85435454b496d to your computer and use it in GitHub Desktop.
Demo describes how to use the rememberCoroutine scope in android
This file contains hidden or 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 ScreenContent(){ | |
Box( | |
modifier = Modifier | |
.fillMaxSize() | |
.background(Color.Yellow) | |
) { | |
val custScope = rememberCoroutineScope() | |
Column( | |
modifier = Modifier | |
.fillMaxWidth() | |
.fillMaxHeight(), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
Button( | |
onClick = { | |
custScope.launch { | |
delay(3000L) | |
println("Hello World!") | |
} | |
}) { | |
Text( | |
text = "Click here", | |
color = Color.White, | |
textAlign = TextAlign.Center | |
) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment