https://kotlinlang.org logo
#android
Title
# android
j

Jazz

10/21/2019, 12:20 PM
Hello My project is MVVM architecture. I use dataBinding with ViewModel and View and ViewModel is AAC ViewModel. I know ViewModel must never reference a view, or it occur memory leak. When onClick called, I pass view by parameter. Although ViewModel doesn’t hold view, is it occured memory leak? android:onClick=“@{(v) -> viewmodel.onClick(v)}”
w

wasyl

10/21/2019, 12:23 PM
as long as you don’t save the view to aa property, it should be fine
Although it’s a good practice to keep the ViewModel completely free of android dependencies like Context or View
👍 5
j

Jazz

10/22/2019, 8:02 AM
Thank you :)