diff options
author | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-05-23 21:49:10 +0200 |
---|---|---|
committer | Jeroen Leenarts <jeroen.leenarts@gmail.com> | 2018-05-23 21:50:42 +0200 |
commit | ae73b78935bf26515eccd1609bcf5bea43cb8451 (patch) | |
tree | 031d1a06c3e7d7b25a9b246a95ce04c81b756f56 /Wireguard/Coordinators/Coordinator.swift | |
parent | Initial commit (diff) | |
download | wireguard-apple-ae73b78935bf26515eccd1609bcf5bea43cb8451.tar.xz wireguard-apple-ae73b78935bf26515eccd1609bcf5bea43cb8451.zip |
Initial project setup.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'Wireguard/Coordinators/Coordinator.swift')
-rw-r--r-- | Wireguard/Coordinators/Coordinator.swift | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Wireguard/Coordinators/Coordinator.swift b/Wireguard/Coordinators/Coordinator.swift new file mode 100644 index 0000000..d1075a3 --- /dev/null +++ b/Wireguard/Coordinators/Coordinator.swift @@ -0,0 +1,34 @@ +// +// 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 } + } + +} |