How to actually reuse a (B)VIPER Module on iOS Apps
Hi Simon, thanks a lot!
Yes the key for reusability lives in the Builder and that’s why it is so important to be part of the name of the architecture itself :-)
Let’s assume in our example you want to reuse the List Module within a custom hosting application. Once you have included the List Module in your project, you can simply re-write (or in some cases subclass) the components of the Module by conforming to the components’ protocol.
The Wireframe is always re-written since it won’t be aware of the next VC (or Module) in your hosting app.
Once that is done you will have to re-write or subclass the Module Builder in order to inject the right implementations. From that moment on just use the new Builder and it is done.
This is a possible Module structure:
And this a possible TyphoonListModuleBuilder:
It is quite simple to create a custom Builder that just re-implements the wireframe method like so:
This is an example with Typhoon as dependency injection (syntax can be weird at the beginning) but of course could work even without it.
Hope is more clear :)