Created
April 11, 2016 07:37
-
-
Save agentk/3cb755e3b90edeefec90d781b2cf7ade to your computer and use it in GitHub Desktop.
WIP ReSwift AppReducer
This file contains 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
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