import 'package:fires_flutter/models/yourLocation.dart'; import 'package:redux/redux.dart'; import 'actions.dart'; final yourLocationsReducer = combineReducers>([ new TypedReducer, AddedYourLocationAction>( _addedYourLocation), new TypedReducer, DeletedYourLocationAction>( _deletedYourLocation), new TypedReducer, UpdateYourLocationAction>( _updateYourLocation), new TypedReducer, ToggledSubscriptionAction>( _toggledSubscriptionAction) ]); List _addedYourLocation( List yourLocations, AddedYourLocationAction action) { return new List.from(yourLocations)..add(action.loc); } List _deletedYourLocation( List yourLocations, DeletedYourLocationAction action) { return yourLocations .where((yourLocation) => yourLocation.id != action.id) .toList(); } List _updateYourLocation( List yourLocations, UpdateYourLocationAction action) { return yourLocations .map((yourLocation) => yourLocation.id == action.loc.id ? action.loc : yourLocation) .toList(); } List _toggledSubscriptionAction( List yourLocations, ToggledSubscriptionAction action) { return yourLocations .map((yourLocation) => yourLocation.id == action.loc.id ? action.loc : yourLocation) .toList(); }