The below sentence refers to a ViewModel having some member variable that would hold data that has activity context. The reason is because a viewModel may live longer than it’s activity/fragment. Holding reference to them would cause leak.

Caution: A ViewModel must never reference a view, Lifecycle, or any class that may hold a reference to the activity context.

In that sense, the example given doesn’t do that. Implementing `lifecycleObserver` doesn’t make one class holding reference to activity context.

Written by

Passionate about learning, and sharing mobile development and others

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store