import 'package:redux/redux.dart'; import '../models/yourLocation.dart'; import 'actions.dart'; final yourLocationsReducer = combineReducers>([ new TypedReducer, AddYourLocationAction>(_addYourLocation), new TypedReducer, DeleteYourLocationAction>( _deleteYourLocation), new TypedReducer, UpdateYourLocationAction>( _updateYourLocation), /* new TypedReducer, ToggleSubscriptionAction>(_toggleSubscriptionAction), new TypedReducer, SubscribeAction>(_setLoadedYourLocations), new TypedReducer, UnSubscribeAction>(_setNoYourLocations), */ ]); List _addYourLocation( List yourLocations, AddYourLocationAction action) { return new List.from(yourLocations)..add(action.loc); } List _deleteYourLocation( List yourLocations, DeleteYourLocationAction action) { return yourLocations .where((yourLocation) => yourLocation.id != action.id) .toList(); } List _updateYourLocation( List yourLocations, UpdateYourLocationAction action) { return yourLocations .map((yourLocation) => yourLocation.id == action.id ? action.loc : yourLocation) .toList(); } /* List _toggleSubscriptionAction(List yourLocations, UpdateYourLocationAction action) { return yourLocations .map((yourLocation) => yourLocation.id == action.id ? action.loc : yourLocation) .toList(); } List _setLoadedYourLocations(List yourLocations, YourLocationsLoadedAction action) { return action.yourLocations; } List _setNoYourLocations(List yourLocations, YourLocationsNotLoadedAction action) { return []; } */