Skip to content

Conversation

@rstn
Copy link

@rstn rstn commented Apr 23, 2025

No description provided.

Copy link
Collaborator

@makzimi makzimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом всё ок, работа выполнена. Но прошу обратить внимание на коммент. На курсовом лучше сделать примерно как я описал.

Comment on lines +9 to +24
@FragmentScope
@Component(
modules = [ProducerFragmentModule::class],
dependencies = [MainActivityComponent::class, ApplicationComponent::class]
)
interface ProducerFragmentComponent {

@Component.Factory
interface Factory {
fun build(
@BindsInstance
contextActivity: Context,
appComponent: ApplicationComponent,
mainActivityComponent: MainActivityComponent,
): ProducerFragmentComponent
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом так сделать можно и оно будет работать.
Но чаще делают так:

Для ProducerFragmentComponent делают
interface ProducerFragmentComponentDependencies
Который определяет просто методы или val что нужно для ProducerFragmentComponent.

И потом, кто-то, реализует этот компонент. Его может реализовать или MainActivityComponent, или это будет прямо новый отдельный класс, который создаст MainActivityComponent внутри себя.

Если будете использовать даггер на курсовом проекте, то лучше именно так сделать. Если будут вопросы - можем на консультациях обсудить это.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants