I have a question about Dagger constructor injections.
If I were to have a constructor injection for one class - however, the constructor also needs to take in a parameter at run time. How do I have the "Bar" in the below example being injected from a provided module?
For ex:
class Foo {
public static final class Factory {
@Inject Factory() {
}
public Foo create(final DynamicRuntimeObj random) {
return new Foo(random);
}
}
Bar mBar;
DynamicRuntimeObj mRandom;
@Inject
Foo(Bar bar, DynamicRuntimeObj random) {
mBar = bar;
mRandom = random;
}
}
Normally, I could create the object like this
Foo foo = new Foo.Factory().create(new DynamicRuntimeObj());
with bar being injected automatically by a provider in one module, but the DynamicRuntimeObj needs to be created at runtime.
Thanks!