import 'package:redux/redux.dart'; import '../models/fireNotification.dart'; import 'actions.dart'; final Reducer> fireNotificationReducer = combineReducers>(>>[ TypedReducer, AddedFireNotificationAction>( _addedFireNotification), TypedReducer, DeletedFireNotificationAction>( _deletedFireNotification), TypedReducer, UpdatedFireNotificationAction>( _updatedFireNotification), TypedReducer, DeletedAllFireNotificationAction>( _deletedAllFireNotifications), TypedReducer, ReadedFireNotificationAction>( _readedFireNotification) ]); List _addedFireNotification( List notifications, AddedFireNotificationAction action) { return List.from(notifications)..insert(0, action.notif); } List _deletedFireNotification( List notifications, DeletedFireNotificationAction action) { return List.from(notifications)..remove(action.notif); } List _updatedFireNotification( List notifications, UpdatedFireNotificationAction action) { return notifications .map((FireNotification notif) => notif.id == action.notif.id ? action.notif : notif) .toList(); } List _readedFireNotification( List notifications, ReadedFireNotificationAction action) { return notifications .map((FireNotification yourLocation) => yourLocation.id == action.notif.id ? action.notif : yourLocation) .toList(); } List _deletedAllFireNotifications( List notifications, DeletedAllFireNotificationAction action) { return []; }