Skip to content

Instantly share code, notes, and snippets.

@atimca
Created June 19, 2020 09:03
Show Gist options
  • Save atimca/64854da8a87283221307c751e734d08f to your computer and use it in GitHub Desktop.
Save atimca/64854da8a87283221307c751e734d08f to your computer and use it in GitHub Desktop.
struct AppState {
var user: User
}
enum AppEvent {
case newUserWasLoaded(User)
}
extension AppEvent {
static func reduce(state: AppState, event: AppEvent) -> AppState {
var state = state
switch event {
case .newUserWasLoaded(let user):
state.user = user
}
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment