-
Notifications
You must be signed in to change notification settings - Fork 174
Dagger2 - дз Лисица #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| interface FragmentReceiverComponentModule { | ||
|
|
||
| @Binds | ||
| fun provideStateFlow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
точно ли нам нужен тут байнд на уровне FragmentReciver
у нас уже есть инстанс, который создается на уровне активити
в ActivityComponentModule и шарится между всеми фрагментами, можно в ресивере использовать именно его.
В случае с ColorGenerator все сделано верно, потому что его использует только ProviderFragment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я не хочу провайдить MutableStateFlow так как RecieverViewModel предназначена только для получения данных, я делаю каст к StateFlow чтобы разграничить ответственность в использовании данной сущности и исключить возможность эмита элементов во флоу из любых мест кроме ProviderViewModel.
При этом инстанс используется тот который создался в ActivityComponentModule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Смотри, идея то понятная и отличная, но у тебя в графе же уже есть инстанс MutableStateFlow и я его могу спокойно заинжектить в ту же ВМ. Может тебе лучше наоборот провайдить StateFlow в активитикомпоненте, тут скастить его в MutableStateFlow ну и закрыть квалифаером для безопасности?
antonkazakov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет. Я прокомментировал ваш с Семеном тред, и добавил маленький коммент про нейминг. В целом все хорошо, и работу я засчитываю
| interface FragmentReceiverComponentModule { | ||
|
|
||
| @Binds | ||
| fun provideStateFlow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Смотри, идея то понятная и отличная, но у тебя в графе же уже есть инстанс MutableStateFlow и я его могу спокойно заинжектить в ту же ВМ. Может тебе лучше наоборот провайдить StateFlow в активитикомпоненте, тут скастить его в MutableStateFlow ну и закрыть квалифаером для безопасности?
| } | ||
|
|
||
| @Module(subcomponents = [ActivityComponent::class]) | ||
| class ApplicationComponentModule No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Имхо не очень хорошая практика модули по именам привязывать к компонентам, у тебя же в принципе модули могут жить в разных компонентах, а конкретно этот вообще необходим только для того чтобы привязать сабкомпоненты, мб его так и назвать?
No description provided.