Skip to content

Instantly share code, notes, and snippets.

@af2905
Last active October 22, 2023 16:57
Show Gist options
  • Save af2905/c3e5265b606743e2a04dbefd082a48de to your computer and use it in GitHub Desktop.
Save af2905/c3e5265b606743e2a04dbefd082a48de to your computer and use it in GitHub Desktop.
lifecycle_scope_extention
/**
* [CoroutineScope] tied to this [LifecycleOwner]'s [Lifecycle].
*
* This scope will be cancelled when the [Lifecycle] is destroyed.
*
* This scope is bound to
* [Dispatchers.Main.immediate][kotlinx.coroutines.MainCoroutineDispatcher.immediate].
*/
public val LifecycleOwner.lifecycleScope: LifecycleCoroutineScope
get() = lifecycle.coroutineScope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment