AnyBuilder
public struct AnyBuilder : ViewControllerBuilder
Type-erased wrapper for ViewControllerBuilder
. It can be used to shorten ViewControllerBuilder
signatures in cases, where generic type information is not needed by consumer of the Route.
Another reason to do this if this generic information obstructs your usage of ViewControllerBuilder
s, for example in cases where you want to create a UITabBarController with array of builders, and each of them has completely different type. In this case, you can convert them to array of AnyBuilder
objects.
For example, when using navigation view builder, signature can become pretty long - NavigationSingleViewEmbeddingBuilderbuilder.asAnyBuilder
which wraps builder in the AnyBuilder
, which can be now used as return type that is much shorter.
-
Creates
AnyBuilder
instance.Declaration
Swift
public init<T>(builder: T, context: T.Context) where T : ViewControllerBuilder
Parameters
builder
builder, whose type is going to be erased.
context
Context to be used when building
ViewController
-
Creates
AnyBuilder
instanceDeclaration
Swift
public init<T>(builder: T) where T : ViewControllerBuilder, T.Context == Void
Parameters
builder
builder, whose type is going to be erased.
-
Creates
AnyBuilder
instanceDeclaration
Swift
public init<T>(buildingBy: @escaping () throws -> T) where T : ViewController
Parameters
buildingBy
closure to build
ViewController
when Route is executed. -
Builds
ViewController
by runningbuilder
closure.Declaration
Swift
public func build(with context: ()) throws -> ViewController
Parameters
context
context is always Void, because Builder and Context types have been erased and are unknown at this point.