Created
June 19, 2020 09:03
-
-
Save atimca/64854da8a87283221307c751e734d08f to your computer and use it in GitHub Desktop.
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
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