Factory
@MainActor
public protocol Factory : AbstractFactory
The Factory protocol should be implemented by the instance that produces any types of the view controllers.
NB
Context represents a payload that you need to pass to your UIViewController and something that distinguishes it from others.
It is not a View Model or some kind of Presenter. It is the missing piece of information. If your view controller requires a
productID to display its content, and the productID is a UUID, then the type of Context is the UUID. The internal logic
belongs to the view controller. Context answers the questions What to I need to present a ProductViewController and Am I
already presenting a ProductViewController for this product.
-
Type of
UIViewControllerthatFactorycan buildDeclaration
Swift
associatedtype ViewController -
Contextto be passed intoUIViewControllerDeclaration
Swift
associatedtype Context
-
Builds a
UIViewControllerthat will be integrated into the stackThrows
TheRoutingErrorif build did not succeed.Declaration
Swift
@MainActor func build(with context: Context) throws -> ViewControllerReturn Value
The built
UIViewControllerinstance.
-
prepare(with:Extension method) Default implementation does nothing
Declaration
Swift
@MainActor mutating func prepare(with context: Context) throws
-
execute(with:Extension method) Prepares the
Factoryand builds itsUIViewControllerDeclaration
Swift
@MainActor func execute(with context: Context) throws -> ViewController
-
build()Extension methodBuilds a
Factory‘s view controller.Declaration
Swift
@MainActor func build() throws -> ViewController -
execute()Extension methodPrepares the
Factoryand builds itsUIViewControllerDeclaration
Swift
@MainActor func execute() throws -> ViewController
-
build()Extension methodBuilds a
Factory‘s view controller.Declaration
Swift
@MainActor func build() throws -> ViewController -
execute()Extension methodPrepares the
Factoryand builds itsUIViewControllerDeclaration
Swift
@MainActor func execute() throws -> ViewController