aboutsummaryrefslogblamecommitdiffstats
path: root/Wireguard/Coordinators/Coordinator.swift
blob: d1075a3bcbe2d386e5ff77f8b47c6228ff6618e2 (plain) (tree)

































                                                                                          
//
//  Coordinator.swift
//  Wireguard
//
//  Created by Jeroen Leenarts on 23-05-18.
//  Copyright © 2018 Wireguard. 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 }
    }

}