File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ Useful links:
2+ - https://dagger.dev/hilt/migration-guide
3+ - https://dagger.dev/hilt/quick-start
4+
5+ Hilt is built on top of Dagger 2 and simplify usage by removing needs to create components manually.
6+
7+ When you create a new feature, you should have the following:
8+
9+ Annotate your Activity with @AndroidEntryPoint
10+ If you have a BottomSheetFragment => Annotate it with @AndroidEntryPoint
11+ Otherwise => Add your Fragment to the FragmentModule
12+ Add your ViewModel.Factory to the MavericksViewModelModule
13+ Makes sure your ViewModel as the following code:
14+
15+ ```
16+ @AssistedFactory
17+ interface Factory: MavericksAssistedViewModelFactory<MyViewModel, MyViewState> {
18+ override fun create(initialState: MyViewState): MyViewModel
19+ }
20+
21+ companion object : MavericksViewModelFactory<MyViewModel, MyViewState> by hiltMavericksViewModelFactory()
22+ ```
23+
24+ ## Some remarks
25+
26+ @MavericksViewModelScope dependencies can't be injected inside Fragments/Activities
27+ You can only inject @Singleton , @MavericksViewModelScope or unscoped dependencies inside Maverick ViewModels
28+ You can access some specific dependencies from Singleton component by using
29+ ```
30+ context.singletonEntryPoint()
31+ ```
32+ Be aware that only the app has been migrated to Hilt and not the SDK.
33+
You can’t perform that action at this time.
0 commit comments