Last active
March 29, 2020 10:50
-
-
Save cipolleschi/bba7b617cc4c9d0603519ef4a2ea9be0 to your computer and use it in GitHub Desktop.
DiceRoller View Model
This file contains hidden or 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 Tempura | |
| struct DiceRollerVM: ViewModelWithState { | |
| private let currentResults: [AppState.DiceState.Die: Int] | |
| init(state: AppState) { | |
| self.currentResults = state.diceState.currentResults | |
| } | |
| func result(for die: AppState.DiceState.Die) -> String { | |
| guard let result = self.currentResults[die] else { | |
| return "-" | |
| } | |
| return "\(result)" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment