1 |
//
|
|
2 |
// RouteComposer
|
|
3 |
// NilFactory.swift
|
|
4 |
// https://github.com/ekazaev/route-composer
|
|
5 |
//
|
|
6 |
// Created by Eugene Kazaev in 2018-2022.
|
|
7 |
// Distributed under the MIT license.
|
|
8 |
//
|
|
9 |
// Become a sponsor:
|
|
10 |
// https://github.com/sponsors/ekazaev
|
|
11 |
//
|
|
12 |
|
|
13 |
import Foundation
|
|
14 |
import UIKit
|
|
15 |
|
|
16 |
/// The dummy struct used to represent the `Factory` that does not build anything.
|
|
17 |
/// Its only purpose is to provide the type safety checks for the `StepAssembly`.
|
|
18 |
///
|
|
19 |
/// For example, the `UIViewController` of the step was already loaded and integrated into a stack by a
|
|
20 |
/// storyboard in a previous step.
|
|
21 |
public struct NilFactory<VC: UIViewController, C>: Factory, NilEntity {
|
|
22 |
|
|
23 |
// MARK: Associated types
|
|
24 |
|
|
25 |
public typealias ViewController = VC
|
|
26 |
|
|
27 |
public typealias Context = C
|
|
28 |
|
|
29 |
// MARK: Methods
|
|
30 |
|
|
31 |
/// Constructor
|
|
32 |
public init() {}
|
81x |
33 |
|
|
34 |
public func prepare(with context: C) throws {
|
2x |
35 |
throw RoutingError.compositionFailed(.init("This factory can not build any UIViewController."))
|
2x |
36 |
}
|
2x |
37 |
|
|
38 |
public func build(with context: C) throws -> VC {
|
1x |
39 |
throw RoutingError.compositionFailed(.init("This factory can not build any UIViewController."))
|
1x |
40 |
}
|
1x |
41 |
|
|
42 |
}
|
|