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