Hi, I have a custom view which gets added and removed in runtime, i.e. its lifecycle could be shorter than the activity. Is there a way provider custom scope for it? Now if VM is scoped to activity, id get the same instance even on a technically another logical instance of the custom view.
Is there a way to provider custom scope? Now I need a "reset" method on the view model which is lame.
Thanks
The Architecture Components ViewModels are made to work with Activities and Fragments, not with the lifecycle of a View.
@florina-muntenescu I have same problem, if we cannot use the ACVM in views, so what would be your suggestion as I need to create a complex custom view which needs to interact with data layer, I prefer to keep the logic inside of custom view class to prevent duplication as it will be using on different activities and fragments.
Most helpful comment
@florina-muntenescu I have same problem, if we cannot use the ACVM in views, so what would be your suggestion as I need to create a complex custom view which needs to interact with data layer, I prefer to keep the logic inside of custom view class to prevent duplication as it will be using on different activities and fragments.