Created
July 2, 2020 10:52
-
-
Save stevencurtis/a61a93f946b81c970a00bb813939de77 to your computer and use it in GitHub Desktop.
reviewcontroller
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
class ViewController: UIViewController, StoreSubscriber { | |
// requirement of the StoreSubscriber protocol | |
typealias StoreSubscriberStateType = AppState | |
@IBOutlet weak var nameLabel: UILabel! | |
func newState(state: AppState) { | |
nameLabel.text = mainStore.state.person[mainStore.state.currentIndex].name | |
} | |
@IBAction func nextAction(_ sender: UIButton) { | |
mainStore.dispatch(NextPerson()) | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// subscribe to state changes | |
mainStore.subscribe(self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment