Conversation
conductor/src/main/java/com/bluelinelabs/conductor/Controller.java
Outdated
Show resolved
Hide resolved
conductor/src/main/java/com/bluelinelabs/conductor/Controller.java
Outdated
Show resolved
Hide resolved
|
I would make the Factory an interface and make the default factory final and hide the implementation. Then you could also just do a identity check in if(FACTORY != DefaultControllerFactory.instance() {
return
}Another approach (which I prefere) would be to pass the factory to conductor upon initialzation: Then in But I really like the idea to get rid of reflection and allow constructor injection. |
8783a95 to
6d415cf
Compare
|
Thanks for the feedback! I've made the interface change. If Dagger doesn't need first-party support for assisted injection, it can be provided through something like AssistedInject or AutoFactory. |
conductor/src/main/java/com/bluelinelabs/conductor/ControllerFactory.java
Show resolved
Hide resolved
6d415cf to
2fd7b55
Compare
ControllerFactory allows Controllers to be provided dependencies through their constructors after a configuration change. This means field injection is no longer a requirement when injecting dependencies into a Controller.
2fd7b55 to
bc4bb1c
Compare
| private boolean isPerformingExitTransition; | ||
| private boolean isContextAvailable; | ||
|
|
||
| static volatile ControllerFactory FACTORY = DefaultControllerFactory.INSTANCE; |
There was a problem hiding this comment.
Controller shouldn't know about any factory
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
|
|
||
| final class DefaultControllerFactory implements ControllerFactory { |
There was a problem hiding this comment.
I think DefaultControllerFactory should implement default logic for creating Controller, but not just be a stub in logic
There was a problem hiding this comment.
We could only do that without extra reflection if the first argument for create was a Class.
|
@PaulWoitaschek I had a look into adding Assuming we store the ControllerFactory in the LifecycleHandler, we would need some way for a |
|
@EricKuck I'm keen to hear your thoughts on this and move this forward |
|
One more thing: if Factory instantiates Controllers, we need a way to create transaction without instantiating controllers ourselves. |
|
ControllerFactory allows Controllers to be provided dependencies through their constructors after a configuration change. This means field injection is no longer a requirement when injecting dependencies into a Controller.
Usage
Currently, you have a single
ControllerFactoryfor your entire app. Having a ControllerFactory perActivity/ViewGroupwould be better but I don't know enough about Conductors internals to make that change.Closes #510.