- napkin
- MultiStageComponentizedBuilder
Class
MultiStageComponentizedBuilder
A builder for napkins that require multiple stages of construction.
class MultiStageComponentizedBuilder<Component, Router, DynamicBuildDependency>
Overview
MultiStageComponentizedBuilder supports building processes where the component needs to be accessed multiple times before finalizing the napkin. Within a single build pass, the same component instance is reused.
Overview
Some napkins require a multi-stage build process:
Access the component to configure dependencies
Build child napkins using the same component
Finally build the parent napkin
This builder ensures component consistency throughout these stages.
Usage
final class ComplexBuilder: MultiStageComponentizedBuilder<ComplexComponent,
ComplexRouting,
ComplexListener> {
init(dependency: ComplexDependency) {
super.init {
ComplexComponent(dependency: dependency)
}
}
func buildChildA() -> ChildARouting {
// Uses the same component instance
return ChildABuilder(dependency: componentForCurrentBuildPass).build()
}
func buildChildB() -> ChildBRouting {
// Uses the same component instance
return ChildBBuilder(dependency: componentForCurrentBuildPass).build()
}
override func finalStageBuild(with component: ComplexComponent,
_ listener: ComplexListener) -> ComplexRouting {
let interactor = ComplexInteractor()
interactor.listener = listener
return ComplexRouter(interactor: interactor,
childA: buildChildA(),
childB: buildChildB())
}
}
See Also
SimpleMultiStageComponentizedBuilder
See Also
ComponentizedBuilder
Topics
Accessing the Component
Building
Initializers
Relationships
Conforms To
Inherited By