Last active
May 22, 2019 04:41
-
-
Save vantruong1094/0b3ce196386e1a5fef21c9960c316c52 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
| class ItemsViewController: UIViewController { | |
| @IBOutlet private weak var tableView: UITableView! | |
| private let viewModel = ItemsViewModel() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| bindViewModel() | |
| viewModel.fetchData() | |
| } | |
| func bindViewModel() { | |
| viewModel.items.bind { [weak self] _ in | |
| guard let self = self else {return} | |
| self.tableView.reloadData() | |
| } | |
| } | |
| } | |
| extension ItemsViewController: UITableViewDataSource { | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return viewModel.numberItems() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment