 import RxCocoa
 import RxMVC
 
-public enum UpDownEvent {
-    case ClickUp
-    case ClickDown
-    case ClickReset
-}
-
-enum UpDownAction {
-    case Increase
-    case Decrease
-    case Reset
-}
-
-struct UpDownController: MapController {
-    typealias Event = UpDownEvent
-    typealias Action = UpDownAction
-    func mapEventToAction(event: Event) -> Action {
-        switch event {
-        case .ClickUp:
-            return Action.Increase
-        case .ClickDown:
-            return Action.Decrease
-        default:
-            return Action.Reset
+class UpDownViewController: UIViewController, View, UserInteractable {
+    enum Event {
+        case ClickUp
+        case ClickDown
+        case ClickReset
+    }
+    
+    enum Action {
+        case Increase
+        case Decrease
+        case Reset
+    }
+    
+    typealias State = Int
+    
+    struct UpDownController: MapController {
+        func mapEventToAction(event: Event) -> Action {
+            switch event {
+            case .ClickUp:
+                return Action.Increase
+            case .ClickDown:
+                return Action.Decrease
+            default:
+                return Action.Reset
+            }
         }
     }
-}
-
-struct UpDownModel: ReducerModel {
-    typealias Action = UpDownAction
-    typealias State = Int
     
-    let initialState = 0
-    func reduce(state: State, with action: Action) -> State {
-        switch action {
-        case .Increase:
-            return state + 1
-        case .Decrease:
-            return state - 1
-        case .Reset:
-            return initialState
+    struct UpDownModel: ReducerModel {
+        let initialState = 0
+        func reduce(state: State, with action: Action) -> State {
+            switch action {
+            case .Increase:
+                return state + 1
+            case .Decrease:
+                return state - 1
+            case .Reset:
+                return initialState
+            }
         }
     }
-}
-
-public class UpDownViewController: UIViewController, View, UserInteractable {
-    public typealias Event = UpDownEvent
-    public typealias State = Int
     
     @IBOutlet weak var countLabel: UILabel!
     @IBOutlet weak var upButton: UIButton!

        combineModel(model, withView: view, controller: controller, andUserInteractable: userInteractable).addDisposableTo(disposeBag)
    }
    
    public override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    
    var disposeBag = DisposeBag()
    
    func update(stateStream: Observable<State>) -> Disposable {
        return stateStream.subscribeNext { (number) in
            self.countLabel.text = "\(number)"
        }
    }
    
    func interact() -> Observable<Event> {
        return [
            self.upButton.rx_tap.map{_ in Event.ClickUp},
            self.downButton.rx_tap.map{_ in Event.ClickDown},
            self.resetButton.rx_tap.map{_ in Event.ClickReset},
            ].toObservable().merge()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let model = UpDownModel()
        let view = self
