Slather logo

Coverage for "ContextSettingTask.swift" : 100.00%

(7 of 7 relevant lines covered)

RouteComposer/Classes/Extra/ContextSettingTask.swift

1
//
2
// RouteComposer
3
// ContextSettingTask.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
/// `ContextTask` that simplifies setting of the context to the `UIViewController` that implements `ContextAccepting` protocol.
17
public struct ContextSettingTask<VC: ContextAccepting>: ContextTask {
18
19
    // MARK: Methods
20
21
    /// Constructor
22
    public init() {}
15x
23
24
    public func prepare(with context: VC.Context) throws {
23x
25
        try VC.checkCompatibility(with: context)
23x
26
    }
23x
27
28
    public func perform(on viewController: VC, with context: VC.Context) throws {
22x
29
        try viewController.setup(with: context)
22x
30
    }
22x
31
32
}