This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DefaultStockListRepository @Inject constructor( | |
| private val remote: StockListRest, | |
| private val local: StockDao, | |
| private val stockLocalConverter: StockLocalConverter | |
| ) : StockListRepository { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| object StockListNetworkModule { | |
| @Provides | |
| fun rest(retrofit: Retrofit): StockListRest = retrofit.create() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // :feature:stock_list:data:wiring/build.gradle.kts | |
| plugins { | |
| id("com.android.library") | |
| id("kotlin-android") | |
| id("kotlin-kapt") | |
| } | |
| android { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module( | |
| includes = [ | |
| StockListDatabaseModule::class, | |
| StockListNetworkModule::class | |
| ] | |
| ) | |
| interface StockListDataModule { | |
| @Binds | |
| @Reusable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component( | |
| modules = [ | |
| StockListDataModule::class | |
| ], | |
| dependencies = [ | |
| NetworkCoreLibApi::class | |
| ] | |
| ) | |
| interface StockListDataComponent : StockListDataApi { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StockListViewModel @Inject constructor( | |
| private val interactor: StockListInteractor | |
| ) : ViewModel() { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StockListViewModelFactory @Inject constructor( | |
| private val provider: Provider<StockListViewModel> | |
| ) : ViewModelProvider.Factory { | |
| @Suppress("Unchecked_Cast") | |
| override fun <T : ViewModel> create(modelClass: Class<T>): T = | |
| provider.get() as T | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class StockListFragment : BaseFragment(R.layout.main_stock_list_fragment) { | |
| @Inject lateinit var factory: StockListViewModelFactory | |
| private val binding by viewBindings(MainStockListFragmentBinding::bind) | |
| private val viewModel by viewModels<StockListViewModel> { factory } | |
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| DaggerStockListFragmentComponent.factory() | |
| .create(featureApi = api.getFeature()) | |
| .inject(this) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component( | |
| dependencies = [ | |
| StockListFeatureApi::class | |
| ] | |
| ) | |
| interface StockListFragmentComponent { | |
| fun inject(target: StockListFragment) | |
| @Component.Factory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| DaggerStockListFragmentComponent.factory() | |
| .create(featureApi = api.getFeature()) // HERE ! | |
| .inject(this) | |
| super.onViewCreated(view, savedInstanceState) | |
| } |