aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Coordinators/Coordinator.swift
blob: 0322383070335aa3e6515e3e1f183d4059877159 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
//  Coordinator.swift
//  WireGuard
//
//  Created by Jeroen Leenarts on 23-05-18.
//  Copyright © 2018 WireGuard LLC. All rights reserved.
//

import Foundation

/// The Coordinator protocol
public protocol Coordinator: class {

    /// Starts the coordinator
    func start()

    /// The array containing any child Coordinators
    var childCoordinators: [Coordinator] { get set }

}

public extension Coordinator {

    /// Add a child coordinator to the parent
    public func addChildCoordinator(_ childCoordinator: Coordinator) {
        self.childCoordinators.append(childCoordinator)
    }

    /// Remove a child coordinator from the parent
    public func removeChildCoordinator(_ childCoordinator: Coordinator) {
        self.childCoordinators = self.childCoordinators.filter { $0 !== childCoordinator }
    }

}