Skip to content

Instantly share code, notes, and snippets.

@vialyx
Created January 5, 2018 08:07
Show Gist options
  • Save vialyx/812bbc5328cb324e9bcf76ffbe42f753 to your computer and use it in GitHub Desktop.
Save vialyx/812bbc5328cb324e9bcf76ffbe42f753 to your computer and use it in GitHub Desktop.
protocol LoginInteractorInput {
func doLogin(login: String, password: String) -> Bool
}
protocol LoginRouterInput {
func openMainScreen()
}
class LoginInteractor: LoginInteractorInput {
func doLogin(login: String, password: String) -> Bool {
// TODO: - Make Network Request
return true
}
}
class LoginRouter: LoginRouterInput {
func openMainScreen() {
// TODO: - Instantiate Main ViewController and show it
}
}
class LoginPresenter {
var interactor: LoginInteractorInput!
var router: LoginRouterInput!
init(interactor: LoginInteractorInput, router: LoginRouterInput) {
self.interactor = interactor
self.router = router
}
// MARK: - Logic
func login() {
let login = "login"
let password = "password"
guard login.isEmpty, password.isEmpty else {
return
}
if interactor.doLogin(login: login, password: password) {
router.openMainScreen()
}
}
}
let router = LoginRouter()
let interactor = LoginInteractor()
let presenter = LoginPresenter(interactor: interactor, router: router)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment