How to call lifecycleScope inside a composable fun...
# compose
s
How to call lifecycleScope inside a composable function?
m
You might be looking for
launchInComposition
https://developer.android.com/jetpack/compose/interop#async
1
s
This is what i'm looking for thanks!
GlobalScope is working fine. But when I try to call launchInComposition it's showing this error! @Manuel Vivo
z
What's the error?
s
m
That’s because
launchInComposition
should be triggered from a composable function. Here’s used in a callback which is out of the composition
t
You can remember:
Copy code
val scope = rememberCoroutineScope()
In the composition and than use it inside of the onClick callback
👍 4
2
m
☝️
195 Views