ursus
03/13/2023, 5:17 PMclass FooViewModel(
private val applicationScope: CoroutineScope
private val someUseCase: UseCase
) {
fun fooClicked() {
applicationScope.launch {
someUseCase.doWhatever() <-----------
}
}
}
the launch lambda captures this, to access the someUseCase field. Is there a way to make the capture explicit somehow, like I could in swift? (There is a temporary viewmodel this leak until the coroutine completes)
Or does this have to be redesigned (i.e. some class that owns the scope and runs the use case on it, so no FooViewModel.this is captured?natario1
03/13/2023, 8:16 PMval someUseCase = someUseCase before launch should do the jobursus
03/14/2023, 12:03 AM