Closed haleibentengf4 closed 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的数量啊 实在是太多了..
1.这种依赖方式是需要都写进来的。 2.可以用Dagger统一管理,也可以不用
我的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的数量啊 实在是太多了..