Last active
November 13, 2020 15:35
-
-
Save panthe/ab276f7df978b71393467437401102f0 to your computer and use it in GitHub Desktop.
A typical Redux reducer
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 'package:redux/redux.dart'; | |
import 'package:flutter_web_with_redux/redux/user/user_actions.dart'; | |
import 'package:flutter_web_with_redux/redux/user/user_state.dart'; | |
final userReducer = combineReducers<UserState>([ | |
TypedReducer<UserState, FetchingUser>(_fetching), | |
TypedReducer<UserState, SetUser>(_setting), | |
TypedReducer<UserState, SavingUser>(_saving), | |
]); | |
UserState _fetching(UserState state, FetchingUser action){ | |
return state.copyWith( | |
isFetching: action.isFetching | |
); | |
} | |
UserState _setting(UserState state, SetUser action){ | |
return state.copyWith( | |
user: action.user | |
); | |
} | |
UserState _saving(UserState state, SavingUser action){ | |
return state.copyWith( | |
isSaving: action.isSaving, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment