Created
February 28, 2019 09:53
-
-
Save alvaroroyo/88153da2f3d7718981ce99f2b3187e49 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 | |
// Protocolo que define los comandos mandados desde la vista al presenter. | |
protocol PersonsModuleInterface: class { | |
func updateView() | |
func showDetailsForPerson(_ person: Person) | |
} | |
// Protocolo que define los comandos mandados desde el interactor al presenter. | |
protocol PersonsInteractorOutput: class { | |
func personsFetched(_ persons: [Person]) | |
} | |
class PersonsPresenter: NSObject, PersonsInteractorOutput, PersonsModuleInterface { | |
// Referencia a la vista (weak para evitar un retain cycle) | |
weak var view: PersonsViewInterface! | |
// Referencia a la interfaz del interactor | |
var interactor: PersonsInteractorInput! | |
// Referencia al router | |
var wireframe: PersonsWireframe! | |
// MARK: PersonsModuleInterface | |
func updateView() { | |
self.interactor.fetchPersons() | |
} | |
func showDetailsForPerson(_ person: Person) { | |
self.wireframe.presentDetailsInterfaceForPerson(person) | |
} | |
// MARK: PersonsInteractorOutput | |
func personsFetched(_ persons: [Person]) { | |
if persons.count > 0 { | |
self.view.showPersonsData(persons) | |
} else { | |
self.view.showNoContentScreen() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment