xiaobailong24 / MVVMArms

Android MVVM Architecture Components based on MVPArms and Android Architecture Components.
Apache License 2.0
424 stars 64 forks source link

请教关于Model 和ViewModel 注入的疑惑 #14

Closed haleibentengf4 closed 5 years ago

haleibentengf4 commented 5 years ago

我的dagger用的不熟,对于项目中 注入 有几个疑问: 1: @Module(includes = {ViewModelFactoryModule.class, WeatherActivityModule.class, WeatherNowFragmentModule.class, WeatherDailyFragmentModule.class}) 要像这样在appModule中吧所有的module都写进来嘛

2 mViewModel = ViewModelProviders.of(this, mViewModelFactory).get(WeatherViewModel.class); viewModel可以通过这种方式创建,为什么还要用dagger注入呢.

另外有没有什么办法 可以减少module的数量啊 实在是太多了..

xiaobailong24 commented 5 years ago

1.这种依赖方式是需要都写进来的。 2.可以用Dagger统一管理,也可以不用