         }
     }
 
-    @IBOutlet weak var tableView: UITableView! {
-        didSet {
-            tableView.register(RoutesCell.self)
-            tableView.tableFooterView = UIView()
-        }
-    }
+    @IBOutlet weak var tableView: UITableView!
 
     private let activityIndicator = ActivityIndicator()
 

import RxSwift
import UIKit

class RoutesViewController : UIViewController {

    @IBOutlet weak var spinner: UIActivityIndicatorView! {
        didSet {

    override func viewDidLoad() {
        super.viewDidLoad()

        initialize(tableView: tableView)

        setupRx()
    }

    private func setupRx() {
        let driver = KatangaBusApiClient().allRoutes()
            .trackActivity(activityIndicator)
            .toArray()
            .asDriver(onErrorJustReturn: [])
        
        bindViewModel(tableView: tableView, driver: driver)
            .addDisposableTo(disposeBag)

        activityIndicator
            .drive(spinner.rx.isAnimating)
            .addDisposableTo(disposeBag)

		tableView.rx.modelSelected(Route.self).subscribe(onNext: { [weak self] in
			let viewModel = RouteDetailViewModel(route: $0)
            self?.performSegue(withIdentifier: "detail", sender: viewModel)
		})
		.addDisposableTo(disposeBag)
    }
    
    func fillCell(row: Int, element: Route, cell: RoutesCell) {
        cell.routeId = element.id
        cell.routeName = element.name
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let vc = segue.destination as! RouteDetailViewController
        
        vc.viewModel = sender as? RouteDetailViewModel
    }

}
