 import RxCocoa
 import ObjectMapper
 
-class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
+class ViewController: UIViewController, UITableViewDelegate {
     
     @IBOutlet weak var tableView: UITableView!
     @IBOutlet weak var refreshButton: UIButton!

    func setup() {
        
        // TableView
        tableView.delegate = self
        tableView.dataSource = self
        tableView.registerNib(UINib(nibName: UserCell.identifier,bundle: nil), forCellReuseIdentifier: UserCell.identifier)
        
        // Stream

            }
        
        responseStream
        .showErrorHUD()
        .map { (responseJSON) -> [User] in
            
            self.hideLoadingHUD()
            
            guard let usersArray = Mapper<User>().mapArray(responseJSON) else { return [] }
            return usersArray
        }
        .bindTo(tableView.rx_itemsWithCellIdentifier(UserCell.identifier, cellType: UserCell.self)) { (row: Int, user: User, cell: UserCell) in
                cell.textLabel?.text = user.username
        }.addDisposableTo(disposeBag)
        
        
        // TableView Selected
        let modelSelectedStream = tableView.rx_modelSelected(User)
        let cellSelectedStream = tableView.rx_itemSelected
        
        Observable.zip(modelSelectedStream, cellSelectedStream) { (user, indexPath) -> () in
            self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
            print(user.username)
            print(user.repos_url)
            print(user.html_url)
        }
        .subscribe()
        .addDisposableTo(disposeBag)
        
    }
    
}

