rememberCoroutineScope for Events
Launch coroutines from callbacks.
Some Work Starts on a Tap
LaunchedEffect runs as composition happens. But scrolling a list or showing a snackbar should start from a callback like onClick, not on entry.
Meet rememberCoroutineScope
A rememberCoroutineScope gives you a CoroutineScope bound to the composition. You keep it around and launch from event handlers.
val scope = rememberCoroutineScope()All lessons in this course
- LaunchedEffect for Coroutines
- rememberCoroutineScope for Events
- DisposableEffect & Cleanup
- derivedStateOf & snapshotFlow