Skip to content

Instantly share code, notes, and snippets.

@nguyenchilong
Created July 5, 2020 09:06
Show Gist options
  • Save nguyenchilong/c0b36a3d302660205f404285dd39d9b3 to your computer and use it in GitHub Desktop.
Save nguyenchilong/c0b36a3d302660205f404285dd39d9b3 to your computer and use it in GitHub Desktop.
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