Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
func mutate(action: Action) -> Observable<Mutation> {
switch action {
case .follow:
return UserService.follow()
.map { Mutation.setFollowing(true) }
.catchErrorJustReturn(Mutation.setFollowing(false))
case .unfollow:
return UserService.unfollow()
.map { Mutation.setFollowing(false) }
.catchErrorJustReturn(Mutation.setFollowing(true))
}
}
func reduce(state: State, mutation: Mutation) -> State {
var newState = state
switch mutation {
case let setFollowing(isFollowing):
newState.isFollowing = isFollowing
}
return newState
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment