Open AngusMorton opened 5 years ago
Really good idea. However if you are looking for a Dagger solution to this I have made this proof of concept which will let you inject members of Controllers. Also there is this library AssistedInject which will let you inject dependencies using the constructor.
You can see my example for dagger. https://github.com/hijamoya/Android-Kotlin-Dagger2-Conductor-Example
@hijamoya Thanks for the sample. But in your sample I don't see constructor injection in controllers. They are still injecting to the member fields.
For reference, here's an example of constructor injection with Fragments before FragmentFactory was introduced: https://github.com/Miha-x64/Flawless/
Currently, when injecting dependencies into a
Controller
, we can't perform constructor injection because Conductor needs to be able to recreate the Controllers after a configuration change. This sucks because field injection is confusing and error-prone.Can we provide an abstraction like a
ControllerFactory
which would behave similarly toandroidx.work.WorkerFactory
in that consumers could override it with their ownControllerFactory
?