Skip to content

Instantly share code, notes, and snippets.

@nguyenchilong
Created July 5, 2020 09:02
Show Gist options
  • Save nguyenchilong/39326bd1a04c0a58e062dd93e53b7b56 to your computer and use it in GitHub Desktop.
Save nguyenchilong/39326bd1a04c0a58e062dd93e53b7b56 to your computer and use it in GitHub Desktop.
mport 'package:redux/redux.dart';
import 'package:saidlty/data/model/notification_data.dart';
import 'package:saidlty/redux/action_report.dart';
import 'package:saidlty/redux/app/app_state.dart';
import 'package:saidlty/redux/notification/notification_actions.dart';
class NotificationsViewModel {
final Notification notification;
final List<Notification> notifications;
final Function(bool) getNotifications;
final ActionReport getNotificationsReport;
NotificationsViewModel({
this.notification,
this.notifications,
this.getNotifications,
this.getNotificationsReport,
});
static NotificationsViewModel fromStore(Store<AppState> store) {
return NotificationsViewModel(
notification: store.state.notificationState.notification,
notifications: store.state.notificationState.notifications.values.toList() ?? [],
getNotifications: (isRefresh) {
store.dispatch(GetNotificationsAction(isRefresh: isRefresh));
},
getNotificationsReport: store.state.notificationState.status["GetNotificationsAction"],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment