```class FooViewModel( private val application...
# compiler
u
Copy code
class 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?
n
val someUseCase = someUseCase
before launch should do the job
u
neat, thanks!