Skip to content

Instantly share code, notes, and snippets.

@devrath
Created January 22, 2023 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devrath/dccc167a98a9f3879ac85435454b496d to your computer and use it in GitHub Desktop.
Save devrath/dccc167a98a9f3879ac85435454b496d to your computer and use it in GitHub Desktop.
Demo describes how to use the rememberCoroutine scope in android
@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