MyCrypto/common/actions/notifications.js

44 lines
939 B
JavaScript
Raw Normal View History

2017-06-21 23:31:59 +00:00
// @flow
export type NOTIFICATION_LEVEL = 'danger' | 'warning' | 'success' | 'info';
export type Notification = {
level: NOTIFICATION_LEVEL,
msg: string,
duration?: number
};
export type ShowNotificationAction = {
type: 'SHOW_NOTIFICATION',
payload: Notification
};
2017-06-22 21:16:21 +00:00
export type CloseNotificationAction = {
2017-06-21 23:31:59 +00:00
type: 'CLOSE_NOTIFICATION',
payload: Notification
};
export type NotificationsAction = ShowNotificationAction | CloseNotificationAction;
export function showNotification(
level: NOTIFICATION_LEVEL = 'info',
msg: string,
duration?: number
): ShowNotificationAction {
return {
type: 'SHOW_NOTIFICATION',
payload: {
level,
msg,
duration
}
};
}
export function closeNotification(notification: Notification): CloseNotificationAction {
return {
type: 'CLOSE_NOTIFICATION',
payload: notification
};
}