Conversation
antonkazakov
left a comment
There was a problem hiding this comment.
Привет. Поправь замечания, пожалуйста
|
|
||
| @Inject | ||
| @ActivityContext | ||
| lateinit var activityContext: Context |
There was a problem hiding this comment.
Его можно через requireContext запросить, не вижу смысла инжектить
| lateinit var activityContext: Context | ||
|
|
||
| lateinit var fragmentProducerComponent: FragmentProducerComponent | ||
| private val colorGenerator = ColorGeneratorImpl() |
There was a problem hiding this comment.
А его как раз нужно инжектить во вьюмодель
| @ActivityContext | ||
| lateinit var activityContext: Context | ||
|
|
||
| lateinit var fragmentProducerComponent: FragmentProducerComponent |
There was a problem hiding this comment.
Зачем тебе ссылка на компонент на уровне класса?
| ): View? { | ||
| return inflater.inflate(R.layout.fragment_a, container, true) | ||
| val activityComponent = (requireActivity() as MainActivity).activityComponent | ||
| fragmentProducerComponent = DaggerFragmentProducerComponent |
There was a problem hiding this comment.
Лучше его создавать в onCreate/onAttach, сейчас он будет пересоздаваться каждый раз когда фрагмент будет класться/доставаться из бекстека
| import javax.inject.Provider | ||
|
|
||
|
|
||
| class FragmentReceiver : Fragment() { |
There was a problem hiding this comment.
Аналогичные замечания
| import javax.inject.Inject | ||
|
|
||
|
|
||
| @ActivityScope |
| fun getFlow(): StateFlow<Int> | ||
| } | ||
|
|
||
| @ActivityScope |
There was a problem hiding this comment.
Здесь тоже. Скоуп нужен если ты будешь инжектить конкретно этот тип, а ты инжектишь IDataKeeper и биндишь его помечая скоупом в даггеровском модуле
| fun inject(fragmentReceiver: FragmentReceiver) | ||
|
|
||
| @ApplicationContext | ||
| fun provideApplicationContext(): Context |
There was a problem hiding this comment.
А зачем тебе провижен метод во фрагмент компоненте? Кто-то будет зависить от FragmentReceiverComponent ?
| fun inject(fragmentProducer: FragmentProducer) | ||
|
|
||
| @ApplicationContext | ||
| fun provideApplicationContext(): Context |
There was a problem hiding this comment.
Все эти провижен методы не нужны
| lateinit var activityComponent: ActivityComponent | ||
|
|
||
| @Inject | ||
| lateinit var dataKeeper: Provider<IDataKeeper> |
There was a problem hiding this comment.
Разве он нужен здесь?
No description provided.