Skip to content

Instantly share code, notes, and snippets.

@agentk
Created April 11, 2016 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agentk/3cb755e3b90edeefec90d781b2cf7ade to your computer and use it in GitHub Desktop.
Save agentk/3cb755e3b90edeefec90d781b2cf7ade to your computer and use it in GitHub Desktop.
WIP ReSwift AppReducer
import ReSwift
struct AppReducer: Reducer {
func handleAction(action: Action, state: AppState?) -> AppState {
var state = state ?? AppState()
state.route = routeReducer(action, state: state.route)
state.signin = signInReducer(action, state: state.signin)
state.createAccount = createAccountReducer(action, state: state.createAccount)
return state
}
}
func signInReducer(action: Action, state: SignInState) -> SignInState {
guard let action = action as? SignInAction else { return state }
var state = state
switch action {
case .SetEmail(let email):
state.email = email
case .SetPassword(let password):
state.password = password
}
return state
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment