If you forget to add static to an abstract module your app will crash at runtime. This should be prevented at compile time.
Example:
Suppose you have a nice abstract module such as the following example:
class SomeOuterClass {
@dagger.Module
public abstract static class Module {
@NonNull
@OnlineScope
@Provides
static A a() {
return new A();
}
}
@OnlineScope
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
interface Component {
@dagger.Component.Builder
interface Builder {
@BindsInstance
Builder interactor(OnlineInteractor interactor);
@BindsInstance
Builder view(Observable<Optional<OnlineView>> view);
Builder parentComponent(ParentComponent component);
Component build();
}
}
}
Next, lets add a new provider to the Module.
@dagger.Module
public abstract static class Module {
@NonNull
@OnlineScope
@Provides
static A a() {
return new A();
}
}
@NonNull
@OnlineScope
@Provides
B b() {
return new B();
}
}
Oops! We forgot to add static to the second provider. This example now crashes at runtime.
If you forget to add static to an abstract module your app will crash at runtime. This should be prevented at compile time.
Example:
Suppose you have a nice abstract module such as the following example:
Next, lets add a new provider to the Module.
Oops! We forgot to add
staticto the second provider. This example now crashes at runtime.