Skip to content

Instantly share code, notes, and snippets.

@jhonatansabadi
Created March 17, 2022 15:54
Show Gist options
  • Save jhonatansabadi/1fee2e92a3d7c5df7374f245c94c53df to your computer and use it in GitHub Desktop.
Save jhonatansabadi/1fee2e92a3d7c5df7374f245c94c53df to your computer and use it in GitHub Desktop.
public val ViewModel.viewModelScope: CoroutineScope
get() {
valscope:CoroutineScope? = this.getTag(JOB_KEY)
if(scope !=null) {
returnscope
}
return setTagIfAbsent(
JOB_KEY,
CloseableCoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment