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) /* new TypedReducer, ToggleSubscriptionAction>(_toggleSubscriptionAction), new TypedReducer, SubscribeAction>(_setLoadedYourLocations), new TypedReducer, UnSubscribeAction>(_setNoYourLocations), */ ]); 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.id ? action.loc : yourLocation) .toList(); } List _toggledSubscriptionAction(List yourLocations, ToggledSubscriptionAction action) { return yourLocations .map((yourLocation) => yourLocation.id == action.loc.id ? action.loc : yourLocation) .toList(); } /* List _setLoadedYourLocations(List yourLocations, YourLocationsLoadedAction action) { return action.yourLocations; } List _setNoYourLocations(List yourLocations, YourLocationsNotLoadedAction action) { return []; } */