Created
July 5, 2020 09:06
-
-
Save nguyenchilong/c0b36a3d302660205f404285dd39d9b3 to your computer and use it in GitHub Desktop.
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 characters
| 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); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment