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

Using Dagger to constructor inject Scenes that also receive saved state #143

Open
NickvanDyke opened this issue Jun 11, 2019 · 4 comments
Open
Labels
type:documentation Documentation is needed

Comments

@NickvanDyke
Copy link

NickvanDyke commented Jun 11, 2019

Is this possible? How would we tell Dagger what to inject for the Scene's savedState constructor parameter? For the time being I have switched to using Koin since with that I can locate the Scene's dependencies, and pass those and the savedState into the Scene's constructor manually.

To be clear, what I'm looking to be able to do is annotate my Scene with @Inject, and then either retrieve it through appComponent.getSomeSpecificScene() or let Dagger inject it into other classes. In both scenarios, the Scene is constructed entirely by Dagger.

@Zhuinden
Copy link

How about assisted injection? https://youtu.be/9fn5s8_CYJI?t=2080

@nhaarman
Copy link
Owner

nhaarman commented Jun 11, 2019

I don't use Dagger myself, but something @Zhuinden mentioned should be possible I guess? Doesn't Dagger support such a thing out of the box? 🤔

This is one thing we do encounter by the way, dealing with clean dependency injection. You can create really nice dependency scopes, but it may cause a fair bit of wiring to set everything up (we do DI manually).

@nhaarman nhaarman added the type:question A question about Acorn label Jun 11, 2019
@NickvanDyke
Copy link
Author

What @Zhuinden linked works well, thanks guys. Wasn't able to find it with my own googling

@nhaarman
Copy link
Owner

Nice! Something like this might fit in the documentation 👍

@nhaarman nhaarman added type:documentation Documentation is needed and removed type:question A question about Acorn labels Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:documentation Documentation is needed
Projects
None yet
Development

No branches or pull requests

3 participants