import 'package:redux/redux.dart'; import 'actions.dart'; import 'package:fires_flutter/models/fireNotification.dart'; final fireNotificationReducer = combineReducers>([ new TypedReducer, AddedFireNotificationAction>( _receivedFireNotification), new TypedReducer, DeletedFireNotificationAction>( _deletedFireNotification), new TypedReducer, DeletedAllFireNotificationAction>( _deletedAllFireNotifications), new TypedReducer, ReadedFireNotificationAction>( _readedFireNotification) ]); List _receivedFireNotification( 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 _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(); }