MyCrypto/common/actions/notifications.js

44 lines
939 B
JavaScript
Raw Normal View History

2017-06-21 16:31:59 -07: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 14:16:21 -07:00
export type CloseNotificationAction = {
2017-06-21 16:31:59 -07: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
};
}