Skip to content
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

@Named annotations in constructor #7

Open
peppered opened this issue Apr 25, 2016 · 0 comments
Open

@Named annotations in constructor #7

peppered opened this issue Apr 25, 2016 · 0 comments

Comments

@peppered
Copy link

peppered commented Apr 25, 2016

Hi!
I'm using Architect-Robot and it seems that Auto-Dagger2 doesn't handle @Named arguments. E.g. I have the following class (with multiple Scheduler arguments):

@AutoStackable(
        component = @AutoComponent(includes = FromActivityAutoComponent.class),
        pathWithView = SignUpView.class
)
@AutoExpose
@DaggerScope(SignUpPresenter.class)
public class SignUpPresenter extends ViewPresenter<SignUpView> {

    private AccountManager accountManager;
    private Scheduler ioScheduler;
    private Scheduler mainScheduler;

    public SignUpPresenter(AccountManager accountManager, @Named("scheduler.io") Scheduler ioScheduler, @Named("scheduler.main") Scheduler mainScheduler) {
        this.accountManager = accountManager;
        this.ioScheduler = ioScheduler;
        this.mainScheduler = mainScheduler;
    }
}

During the build I get the following error:

Error:(19, 8) error: rx.Scheduler cannot be provided without an @Provides-annotated method.
architect.commons.view.PresentedLinearLayout.presenter
[injected field of type: ui.signup.SignUpPresenter presenter]
ui.signup.stackable.SignUpStackable.Module.providesPresenter(services.AccountManager accountManager, rx.Scheduler ioScheduler, rx.Scheduler mainScheduler)
[parameter: rx.Scheduler ioScheduler]

And I found that generated module looks as follows (without @Named annotations)

@dagger.Module
public class Module {
  @Provides
  @DaggerScope(SignUpPresenter.class)
  public SignUpPresenter providesPresenter(AccountManager accountManager, Scheduler ioScheduler, Scheduler mainScheduler) {
    return new SignUpPresenter(accountManager, ioScheduler, mainScheduler);
  }
}
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

No branches or pull requests

1 participant