SHARE
TWEET

Untitled

a guest Oct 19th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import RxSwift
  2. import RxCocoa
  3.  
  4. class TodoListViewController: UIViewController {
  5.     @IBOutlet var tableView: UITableView!
  6.     @IBOutlet var addButton: UIBarButtonItem!
  7.  
  8.     private let viewModel = TodoListViewModel()
  9.     private let disposeBag = DisposeBag()
  10.    
  11.     override func viewDidLoad() {
  12.         super.viewDidLoad()
  13.         setupViews()
  14.         setupBindings()
  15.     }
  16.  
  17.     private func setupViews() {
  18.         tableView.register(UINib(nibName: "TodoListTableViewCell", bundle: nil), forCellReuseIdentifier: "TodoListTableViewCell")
  19.     }
  20.  
  21.     private func setupBindings() {
  22.         // 1
  23.         viewModel
  24.             .todoListSectionsObservable
  25.             .bind(to: tableView.rx.items(dataSource: viewModel.dataSource))
  26.             .disposed(by: disposeBag)
  27.  
  28.         addButton
  29.             .rx
  30.             .tap
  31.             .bind(to: viewModel.addButtonObserver)
  32.             .disposed(by: disposeBag)
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top