         addViewsToHierarchy([emptyView,tableView])
         setupConstraints()
         setupStyles()
+        bindComponents()
     }
     
 

//

import UIKit

class RepositoryListViewController: UIViewController {
    
    fileprivate var emptyView = EmptyView()
    
    fileprivate var tableView = UITableView(frame: CGRect.zero, style: .plain)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setup()
    }

    override func didReceiveMemoryWarning() {

    func setupStyles() {
        self.view.backgroundColor = .white
        emptyView.isHidden = true
        tableView.estimatedRowHeight = 108
        tableView.rowHeight = UITableViewAutomaticDimension
        tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0)
    }
    
    func bindComponents() {
        currentState.asObservable().subscribe(onNext: { [weak self] in
            if $0 == .loading {
                self?.presenter?.loadRepositories()
            }
        }).addDisposableTo(disposeBag)
        currentState.asObservable().map { $0 == .notShowingRepositories ? EmptyViewState.showingError : EmptyViewState.loading }.bind(to: emptyView.currentState).addDisposableTo(disposeBag)
        currentState.asObservable().map { $0 == .showingRepositories }.bind(to: emptyView.rx.isHidden).addDisposableTo(disposeBag)
        currentState.asObservable().map { $0 != .showingRepositories }.bind(to: tableView.rx.isHidden).addDisposableTo(disposeBag)
    }
    
}

