AutoDaggerViewModelCoroutineScopeComponent

A Dagger module which provides a CoroutineScope that is tied to the lifecycle of a ViewModel.

The provided scope is qualified with ViewModelSpecific and will be canceled when the viewmodel is cleared and it ses a SupervisorJob and the [Dispatchers].Main.immediate dispatcher.

To inject:

@HiltViewModel
class MyViewModel @Inject constructor(
@ViewModelSpecific
private val viewModelScope: CoroutineScope
) : ViewModel()

Since

1.0.0

Functions

Link copied to clipboard
fun provideViewModelScope(lifecycle: ViewModelLifecycle): CoroutineScope