What if i have to pass a constructor parameter to viewmodel? #771
Unanswered
yuvaraj119
asked this question in
Q&A
Replies: 1 comment
-
You can either pass the dependencies manually or use a DI framework (like
Usually, ViewModels are not needed with Decompose. If you need to survive configuration changes on Android: see the doc. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What if i have to pass a constructor parameter to viewmodel?
something like this
First approach:
class XScreenViewModel(val iXScreen: IXScreen):ViewModel() { }
OR
Second approach
If i make my viewmodel component will that cause issue?
class SplashScreenViewModel(componentContext: ComponentContext) : ViewModel(), IXScreen, ComponentContext by componentContext {
best would be First if it works. This will isolate the whole decompose component from actual code and later at somepoint if we have to switch the Navigation it will be easy to do.
Beta Was this translation helpful? Give feedback.
All reactions