antonicg / cryptodata

Apache License 2.0
154 stars 31 forks source link

[Question] What is the purpose of DaggerViewModelFactory? #1

Open agustinsivoplas opened 6 years ago

agustinsivoplas commented 6 years ago

Why you have to override the in ViewModelFactory? What is the purpose DaggerViewModelFactory? What is wrong with the default implementation of ViewModelFactory?

antonicg commented 6 years ago

The purpose is to allow the dependency injection with dagger to ViewModels.

agustinsivoplas commented 6 years ago

Thanks, but in that case all view models will be singleton? Whats happen if I have multiple instances of a fragment (the same fragment) but I dont want to share the same view model?

mochadwi commented 5 years ago

Thanks, but in that case, all view models will be a singleton? Whats happens if I have multiple instances of a fragment (the same fragment) but I don't want to share the same view model?

I think with Koin you can get this. sharedViewModel if you want to shared between multiple instances of a fragment, use viewModel to avoid using same view model.

But, in Dagger, I still have no experiences about it. @agustinsivoplas