Skip to content

Instantly share code, notes, and snippets.

View AndreyPanov's full-sized avatar
🤚

Andrei Panov AndreyPanov

🤚
View GitHub Profile
@AndreyPanov
AndreyPanov / Presentable.swift
Created January 12, 2017 16:12
Presentable
protocol Presentable {
func toPresent() -> UIViewController?
}
@AndreyPanov
AndreyPanov / MakeItemDetailOutput.swift
Created January 12, 2017 16:13
makeItemDetailOutput
func makeItemDetailOutput(item: Item) -> ItemDetailView {
let controller = ItemDetailController.controllerFromStoryboard(.items)
controller.item = item
return controller
}
@AndreyPanov
AndreyPanov / ItemModuleFactory.swift
Created January 12, 2017 16:14
ItemModuleFactory
protocol ItemModuleFactory {
func makeItemsOutput() -> ItemsListView
func makeItemDetailOutput(item: ItemList) -> ItemDetailView
}
@AndreyPanov
AndreyPanov / ModuleFactoryImp.swift
Created January 12, 2017 16:14
ModuleFactoryImp
class ModuleFactoryImp:
AuthModuleFactory,
ItemModuleFactory,
ItemCreateModuleFactory,
SettingsModuleFactory {
/* implementation */
}
moduleA.onNext = { [weak self] dict in
self?.storage.dict = dict
self?.showModuleB()
}
@AndreyPanov
AndreyPanov / Reflection.swift
Last active March 17, 2017 17:15
Reflection Generic Properties
import UIKit
protocol Reflectable {
func properties<T>() -> [T]
}
extension Reflectable {
func properties<T>() -> [T] {
var s = [T]()
Mirror(reflecting: self).children.forEach { property in
private func runAuthFlow() {
let coordinator = coordinatorFactory.makeAuthCoordinatorBox(router: router)
coordinator.finishFlow = { [weak self, weak coordinator] in
isAutorized = true
self?.start() //here we'll check instruction
self?.removeDependency(coordinator)
}
addDependency(coordinator)
coordinator.start()
}
struct DeepLinkURLConstants {
static let Onboarding = "onboarding"
static let Items = "items"
static let Item = "item"
static let Settings = "settings"
}
enum DeepLinkOption {
case onboarding
case items
protocol Coordinator: class {
func start()
func start(with option: DeepLinkOption?)
}
override func start(with option: DeepLinkOption?) {
//start with deepLink
if let option = option {
switch option {
case .onboarding: runOnboardingFlow()
case .signUp: runAuthFlow()
default: childCoordinators.forEach { coordinator in
coordinator.start(with: option)
}
}