Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AlekseyPleshkov/383b1573bdbb302dbe4eebb22ad20cef to your computer and use it in GitHub Desktop.

Select an option

Save AlekseyPleshkov/383b1573bdbb302dbe4eebb22ad20cef to your computer and use it in GitHub Desktop.
/// Протокол логики презентации
protocol HomePresentationLogic: class {
/// Метод форматирования полученных данных с Interactor'a
func presentUser(_ response: HomeModels.FetchUser.Response)
}
final class HomePresenter: HomePresentationLogic {
/// Ссылка на логику отображения View Controller'a
weak var viewController: HomeDisplayLogic?
func presentUser(_ response: HomeModels.FetchUser.Response) {
// Для примера отформатируем номер телефона
let formattedPhone = response.userPhone.replacingOccurrences(of: "-", with: " ")
// Создаем экземляр ViewModel для отправки в View Controller
let viewModel = HomeModels.FetchUser.ViewModel(userPhone: formattedPhone, userEmail: response.userEmail)
// Вызываем метод логики отображения у View Controller'a
viewController?.displayUser(viewModel)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment