Created
May 28, 2020 21:58
-
-
Save rlnucci/b8e61658e853f4a963c64ce955206788 to your computer and use it in GitHub Desktop.
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
| typealias CustomViewDelegate = UITableViewDelegate & UITableViewDataSource | |
| protocol CustomViewProtocol where Self: UIView { | |
| func render(data: String) | |
| func renderLoadingState() | |
| } | |
| final class ExampleViewController: UIViewController { | |
| private let customView: CustomViewProtocol | |
| private let presenter: ExamplePresenter | |
| init(customView: CustomViewProtocol, presenter: ExamplePresenter) { | |
| self.customView = customView | |
| self.presenter = presenter | |
| super.init(nibName: nil, bundle: nil) | |
| } | |
| required init?(coder aDecoder: NSCoder) { | |
| fatalError() | |
| } | |
| override func viewWillAppear(_ animated: Bool) { | |
| super.viewWillAppear(animated) | |
| // Should test it | |
| customView.renderLoadingState() | |
| presenter.fetchData() | |
| } | |
| override func loadView() { | |
| view = customView | |
| } | |
| } | |
| extension ExampleViewController: PresenterDelegate { | |
| func didFetch(data: String) { | |
| // test it | |
| customView.render(data: data) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment