Skip to content

Instantly share code, notes, and snippets.

@cipolleschi
Last active March 29, 2020 10:50
Show Gist options
  • Select an option

  • Save cipolleschi/bba7b617cc4c9d0603519ef4a2ea9be0 to your computer and use it in GitHub Desktop.

Select an option

Save cipolleschi/bba7b617cc4c9d0603519ef4a2ea9be0 to your computer and use it in GitHub Desktop.
DiceRoller View Model
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