This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseCoordinator { | |
var childCoordinators: [Coordinator] = [] | |
// add only unique object | |
func addDependency(_ coordinator: Coordinator) { | |
for element in childCoordinators { | |
if element === coordinator { return } | |
} | |
childCoordinators.append(coordinator) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func push(_ module: Presentable?) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Presentable { | |
func toPresent() -> UIViewController? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func makeItemDetailOutput(item: Item) -> ItemDetailView { | |
let controller = ItemDetailController.controllerFromStoryboard(.items) | |
controller.item = item | |
return controller | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol ItemModuleFactory { | |
func makeItemsOutput() -> ItemsListView | |
func makeItemDetailOutput(item: ItemList) -> ItemDetailView | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ModuleFactoryImp: | |
AuthModuleFactory, | |
ItemModuleFactory, | |
ItemCreateModuleFactory, | |
SettingsModuleFactory { | |
/* implementation */ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
moduleA.onNext = { [weak self] dict in | |
self?.storage.dict = dict | |
self?.showModuleB() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol Reflectable { | |
func properties<T>() -> [T] | |
} | |
extension Reflectable { | |
func properties<T>() -> [T] { | |
var s = [T]() | |
Mirror(reflecting: self).children.forEach { property in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
var rootController: UINavigationController { | |
return self.window!.rootViewController as! UINavigationController | |
} | |
private lazy var applicationCoordinator: Coordinator = self.makeCoordinator() | |
func application(_ application: UIApplication, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate enum LaunchInstructor { | |
case main, auth, onboarding | |
static func configure(tutorialWasShown: Bool, isAutorized: Bool) -> LaunchInstructor { | |
switch (tutorialWasShown, isAutorized) { | |
case (true, false), (false, false): return .auth | |
case (false, true): return .onboarding | |
case (true, true): return .main | |
} | |
} |