Created
October 21, 2019 19:16
-
-
Save t0rn/c771365bce0e8b0025faf8a2d9a9d2a1 to your computer and use it in GitHub Desktop.
This file contains 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 Foundation | |
protocol DelegateProtocol: class { | |
} | |
protocol Delegatable { | |
associatedtype DelegateType: DelegateProtocol | |
var delegate: DelegateType? { get set } | |
} | |
protocol PresenterProtocol : Delegatable { | |
associatedtype View: ViewProtocol | |
var view:View {get} | |
} | |
protocol ViewProtocol: Delegatable { | |
} | |
protocol CoordinatorProtocol : Delegatable { | |
associatedtype From: ViewProtocol | |
associatedtype Destination: ViewProtocol | |
var from: From {get} | |
var destination:Destination {get} | |
} | |
class ListView<Delegate:DelegateProtocol> : ViewProtocol { | |
typealias DelegateType = Delegate | |
var delegate: Delegate? | |
init(delegate:Delegate? = nil) { | |
self.delegate = delegate | |
} | |
} | |
class ListPresenter<ListViewType:ViewProtocol, Delegate:DelegateProtocol> : PresenterProtocol { | |
typealias View = ListViewType | |
var view: ListViewType | |
var delegate: Delegate? | |
init(view:ListViewType,delegate:Delegate? = nil) { | |
self.view = view | |
self.delegate = delegate | |
} | |
} | |
class ListCoordinator<Delegate:DelegateProtocol,FromType:ViewProtocol, DestinationType:ViewProtocol> : CoordinatorProtocol { | |
typealias From = FromType | |
typealias Destination = DestinationType | |
typealias DelegateType = Delegate | |
var from: FromType | |
var destination: DestinationType | |
var delegate: Delegate? | |
init(from:FromType, | |
destination:DestinationType, | |
delegate:Delegate? = nil) { | |
self.from = from | |
self.destination = destination | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment