Last active
December 7, 2017 09:57
-
-
Save alexobenauer/987950387e58486ce08646d4730dde39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
class ViewController: NSViewController, StoreSubscriber { | |
@IBOutlet weak var counterLabel: NSTextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
store.subscribe(self) | |
} | |
@IBAction func userClickedPlus(_ sender: Any) { | |
store.dispatch(action: IncreaseAction(increaseBy: 1)) | |
} | |
@IBAction func userClickedMinus(_ sender: Any) { | |
store.dispatch(action: DecreaseAction(decreaseBy: 1)) | |
} | |
func newState(state: State) { | |
counterLabel.stringValue = "\((state as? AppState)?.counter ?? 0)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment