1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/models/global_notification_model.js
2016-04-13 10:39:19 +02:00

22 lines
636 B
JavaScript

'use strict';
export default class GlobalNotificationModel {
constructor(message, type = 'success', dismissAfter = 5000) {
if (type !== 'success' && type !== 'danger') {
throw new Error(`A notification's type either has to be success, or danger. Not: ${type}`);
}
if (message) {
this.message = message;
} else {
console.logGlobal(new Error('Global notification did not contain a message and was ignored'), {
dismissAfter,
type
});
}
this.dismissAfter = dismissAfter;
this.type = type;
}
}