Skip to content

Dagger Tutorial Missing Step to Remove UserCommandsModule #4789

Description

@jeqcho

I can't find a GitHub source for the tutorial webpage, but the tutorial examples are available in this repo so I will flag this issue here, though note that it is an issue of the tutorial webpage and not of the dagger library.

At the Deposit After Login section, it is mentioned to

We need to include UserCommandsRouter.InstallationModule in our @Component annotation

which is followed by the code.

@Singleton
@Component(
    modules = {
      ...
      UserCommandsRouter.InstallationModule.class,
    })
interface CommandProcessorFactory {
  CommandProcessor commandProcessor();
}

Note that at this step, UserCommandsModule should also be removed from the modules of this Component, so it's suggested to show all of the modules and clarify that UserCommandsModule is removed

@Singleton
@Component(
        modules = {
            LoginCommandModule.class,
            HelloWorldModule.class,
            SystemOutModule.class, // UserCommandsModule.class is removed
            UserCommandsRouter.InstallationModule.class
    })
interface CommandProcessorFactory {
  CommandProcessor commandProcessor();
}

Otherwise the build fails. Currently, the sentence saying this code movement is too subtle and nested inside the explanations:

The @Subcomponent annotation defines what modules Dagger should know about when creating instances for this subcomponent only. Just like @Component, it can take a list of modules: we’ve moved the UserCommandsModule that declares our DepositCommand here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions