This pull request aims to achieve a mechanism to provide dependencies to VIPER modules.
The createModule method of Router class receives a ServiceLocator object as argument. This object provides all the dependencies of the app and will be used to provides dependencies of the module.
In this way, the service locator object is passed between modules.
An example of ServiceLocator implementation can be found here
I understand that this pull request tie the user to use the proposed dependency injection mechanism, so I will understand that the PR will be rejected. Anyway, I hope it will be useful for someone.
This pull request aims to achieve a mechanism to provide dependencies to VIPER modules.
The
createModule
method ofRouter
class receives aServiceLocator
object as argument. This object provides all the dependencies of the app and will be used to provides dependencies of the module.In this way, the service locator object is passed between modules.
An example of ServiceLocator implementation can be found here
Apart from these modifications, I have moved the implementation of some protocols to extensions in order to improve legibility (https://github.com/raywenderlich/swift-style-guide#protocol-conformance)
I understand that this pull request tie the user to use the proposed dependency injection mechanism, so I will understand that the PR will be rejected. Anyway, I hope it will be useful for someone.
Thanks!