Aug 18, 2023
I'd say this is an anti-pattern. ViewModels were not designed to be used this way and this article doesn't address downsides:
1. ViewModel is attached to neares fragment/activity, not to the view itself
2. because of 1 multiple custom views will share the same ViewModel
3. when custom view dies - viewmodel continues to exist until owner dies