Skip to content

Instantly share code, notes, and snippets.

@atimca
Created July 8, 2020 16:22
Show Gist options
  • Save atimca/15e97150f720340fc09e4a919fbf8249 to your computer and use it in GitHub Desktop.
Save atimca/15e97150f720340fc09e4a919fbf8249 to your computer and use it in GitHub Desktop.
extension State {
static func reduce(state: State, event: Event) -> State {
var state = state
switch event {
case .dataLoaded(let data):
state = .loaded(data: data)
case .loadData:
state = .loading
}
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment