Skip to content

Instantly share code, notes, and snippets.

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 saqib-github-commits/a130b84f1e06ce2a220054bcd40733cc to your computer and use it in GitHub Desktop.
Save saqib-github-commits/a130b84f1e06ce2a220054bcd40733cc to your computer and use it in GitHub Desktop.
@Composable
inline fun rememberCoroutineScope(
getContext: @DisallowComposableCalls () -> CoroutineContext = { EmptyCoroutineContext }
): CoroutineScope {
val composer = currentComposer
val wrapper = remember {
CompositionScopedCoroutineScopeCanceller(
createCompositionCoroutineScope(getContext(), composer)
)
}
return wrapper.coroutineScope
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment