Created
July 5, 2020 09:06
-
-
Save nguyenchilong/c0b36a3d302660205f404285dd39d9b3 to your computer and use it in GitHub Desktop.
Revisions
-
nguyenchilong created this gist
Jul 5, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ final notificationReducer = combineReducers<NotificationState>([ TypedReducer<NotificationState, SyncNotificationsAction>(_syncNotifications), ]); NotificationState _syncNotifications( NotificationState state, SyncNotificationsAction action) { for (var notification in action.notifications) { state.notifications.update(notification.id.toString(), (v) => notification, ifAbsent: () => notification); } state.page.currPage = action.page.currPage; state.page.pageSize = action.page.pageSize; state.page.totalCount = action.page.totalCount; state.page.totalPage = action.page.totalPage; return state.copyWith(notifications: state.notifications); }