-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Optional injections #423
Comments
I'm confused. Why would you need to reference your activity-wide objects from the first invocation of your app-wide graph. Or rather, why are you staging tests for activities without the activity-wide graph, which it sounds like you're trying to do. I think optional in this case would be really unsafe, even if we supported it, as it would end up with your activities being agnostic to the availability of activity-scoped things, which could easily lead to someone forgetting to include something, etc. Can you talk a bit more about your set up, and why you would need this particular organization of code and flow in these tests? I may be missing something. |
@cgruber The issue is basically that I have some components / singletons that need to be created and also partially mocked before the activity is created / fully set up, otherwise I suffer from test flakiness. So while I'd really like to just create one, the activity-scoped object graph, and inject stuff from this into my test, the creation of this graph requires a call to Right now I help myself by calling |
Butter Knife does lookups not injection. With different layout configurations there's a very real possibility some views are present only in certain situations and completely absent in others. It refers to these view lookups as "injection" purely as a joke for RoboGuice converts. |
Well, nicely put, point taken :-D I think Guice' interpretation of |
Yeah - we don't (at present) support @nullable and nullable providers. On 7 July 2014 11:12, Thomas Keller [email protected] wrote:
|
I have a (somewhat) weird use case: In my app I have two object graphs, one for app-wide and one for activity-wide components, while the latter extends (plusses) from the former.
Now in my instrumentation tests I need to be able to inject all components, though I need to access the app-wide components already before I can inject the activity-wide ones. What I do then is that I call
inject()
twice, once with the base object graph and once with the (extended) activity graph.The problem now is of course that the activity-wide components aren't link-satisfyable during the base injection as they're later injected. I know that ButterKnife has an
@Optional
annotation for such "dependencies", now is there something similar for Dagger as well?The text was updated successfully, but these errors were encountered: