Last active
October 5, 2016 01:13
-
-
Save ronanrodrigo/6eaad507aebb92a64c5bd178f56bb43b to your computer and use it in GitHub Desktop.
VIPER files
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
| public struct CreateCustomerInteractor { | |
| var customerRepository: CustomerRepository | |
| var createCustomerOutputPresenter: CreateCustomerOutputPresenter | |
| public init(customerRepository: CustomerRepository, createCustomerOutputPresenter: CreateCustomerOutputPresenter) { | |
| self.customerRepository = customerRepository | |
| self.createCustomerOutputPresenter = createCustomerOutputPresenter | |
| } | |
| public func create(customer: Customer) { | |
| // Realiza uma chamada ao respository que foi injetado através do construtor dessa classe. | |
| // Aqui é um exemplo clássico do conceito de regra de dependência. O interactor não precisa saber | |
| // se o repository vai salvar o cliente num banco, numa API ou em memória. Apenas que seja salvado | |
| // e o repository se vira. | |
| customerRepository.create(customer) | |
| // Após terminar seu serviço principal, o interactor chama o Presenter de Output, para mostrar o que aconteceu. | |
| createCustomerOutputPresenter.show() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment