https://kotlinlang.org logo
#koin
Title
# koin
k

KotlinLeaner

10/04/2022, 3:07 PM
Hey guys, what is the best way of passing context in
viewmodel
. When I am trying to pass
context
through constructions of
viewmodel
it complains about
This field leaks a context object
.
m

Mustafa Ozhan

10/04/2022, 3:38 PM
The best way is, not to pass context into viewmodel 🙂 Viewmodels shouldn’t be aware of the context
m

Morgane Soula

10/04/2022, 4:11 PM
ViewModel should be context-free since you should unit test it
k

KotlinLeaner

10/04/2022, 4:12 PM
ok sure, thanks for lemme know
2 Views