forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
Description
The problem:
I can't provide Lazy<T> like this:
@Provides
public Lazy<DrawerLayout> provideDrawerError:(17, 10) error: android.support.v4.widget.DrawerLayout cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method.
xx.DocumentListFragment.drawer
[injected field of type: dagger.Lazy<android.support.v4.widget.DrawerLayout> drawer]
Because of that some users of T may try to @Inject T dependency instead of using Lazy. Dagger have no idea that the dependency does not exist at the moment of injection so it may inject null or just crash inside of a module.
Solution: allow to provide Lazy<T> directly.
A temporary workaround I'm using (simplified):
public interface Delayed<T> {
T get();
}
@Provides
Delayed<DrawerLayout> provideDrawerLayout() {...}
@Inject Delayed<DrawerLayout> drawer;Reactions are currently unavailable