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 | |
struct PostsWorker { | |
// MARK: - Private Properties | |
private let networkWorker = NetworkWorker() | |
private let postsURL = URL(string: "https://jsonplaceholder.typicode.com/posts") | |
// MARK: - Public Methods |
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 | |
struct HomeWorker { | |
// MARK: - Private Properties | |
private let networkWorker = NetworkWorker() | |
private let usersURL = URL(string: "https://jsonplaceholder.typicode.com/users") | |
// MARK: - Public Methods |
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 | |
struct NetworkWorker { | |
// MARK: - Private Properties | |
private let session = URLSession.shared | |
// MARK: - Public Methods |
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 UIKit | |
/// Помечен как @objc для создания селектора | |
/// в методе prepare во View Controller'e | |
@objc protocol HomeRoutingLogic { | |
/// Переход на Detail View Controller | |
func routeToDetail(segue: UIStoryboardSegue?) | |
} |
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
final class HomeViewController: UIViewController { | |
// ... | |
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | |
// Если у Segue есть идентификатор | |
if let scene = segue.identifier { | |
// Создаем селектор, для вызова метода с этим именем и параметрами в Router | |
// router?.routeToNAME(segue:) | |
let selector = NSSelectorFromString("routeTo\(scene)WithSegue:") |
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
/// Протокол логики презентации | |
protocol HomePresentationLogic: class { | |
/// Метод форматирования полученных данных с Interactor'a | |
func presentUser(_ response: HomeModels.FetchUser.Response) | |
} | |
final class HomePresenter: HomePresentationLogic { | |
/// Ссылка на логику отображения View Controller'a |
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
// Interactor | |
/// Протокол бизнес логики Interactor'a | |
protocol HomeBusinessLogic: class { | |
/// Метод получения данных из сети или других источников | |
func fetchUser(_ request: HomeModels.FetchUser.Request) | |
} | |
final class HomeInteractor: HomeBusinessLogic { |
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
// ViewController | |
/// Протокол логики для отображения подготовленной информации | |
protocol HomeDisplayLogic: class { | |
/// Метод логики отображения данных | |
func displayUser(_ viewModel: HomeModels.FetchUser.ViewModel) | |
} | |
final class HomeViewController: UIViewController { |
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
// Models | |
/// Модель для передачи данных в VIP цикле | |
enum HomeModels { | |
/// Набор запросов для одного VIP цикла | |
enum FetchUser { | |
/// Запрос к Interactor из View Controller | |
struct Request { | |
let userName: String |
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
methods: { | |
// Иницилизация события | |
videoInit: function () { | |
// Получаем объект с видео | |
this.video = document.querySelector('.js-video') | |
// Событие на прокрутку "колеса мыши" | |
document.addEventListener('wheel', (e) => { | |
this.videoStep(e.deltaY) | |
e.preventDefault() |
NewerOlder