2016-12-01 16:44:03 +01:00

39 lines
618 B
JavaScript

/*
*
* NotificationProvider actions
*
*/
import {
SHOW_NOTIFICATION,
HIDE_NOTIFICATION,
} from './constants';
import { dispatch } from '../../app';
let nextNotificationId = 0;
export function showNotification(message, status) {
nextNotificationId++;
// Start timeout to hide the notification
((id) => {
setTimeout(() => {
dispatch(hideNotification(id));
}, 5000);
})(nextNotificationId);
return {
type: SHOW_NOTIFICATION,
message,
status,
id: nextNotificationId,
};
}
export function hideNotification(id) {
return {
type: HIDE_NOTIFICATION,
id,
};
}