Skip to content

Instantly share code, notes, and snippets.

@xrigau
Created April 16, 2018 16:17
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 xrigau/a665affbd76a329c80d167be675b8ab2 to your computer and use it in GitHub Desktop.
Save xrigau/a665affbd76a329c80d167be675b8ab2 to your computer and use it in GitHub Desktop.
Introduction to Redux in Flutter (reducer.dart)
AppState appReducer(AppState state, action) => AppState(toDoListReducer(state.toDos, action), listStateReducer(state.listState, action));
final Reducer<List<ToDoItem>> toDoListReducer = // Boilerplate ignored
final Reducer<ListState> listStateReducer = combineReducers<ListState>([
TypedReducer<ListState, DisplayListOnlyAction>(_displayListOnly),
TypedReducer<ListState, DisplayListWithNewItemAction>(_displayListWithNewItem),
]);
ListState _displayListOnly(ListState listState, DisplayListOnlyAction action) => ListState.listOnly;
ListState _displayListWithNewItem(ListState listState, DisplayListWithNewItemAction action) => ListState.listWithNewItem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment