1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00
onion/js/models/global_notification_model.js

23 lines
707 B
JavaScript
Raw Normal View History

'use strict';
export default class GlobalNotificationModel {
2015-06-10 15:49:46 +02:00
constructor(message, type = 'info', dismissAfter = 5000) {
if (message) {
2015-06-09 13:36:09 +02:00
this.message = message;
} else {
console.logGlobal(new Error('Global notification did not contain a message and was ignored'), {
dismissAfter,
type
});
2015-06-09 13:36:09 +02:00
}
if (type === 'info' || type === 'success' || type === 'warning' || type === 'danger') {
2015-06-09 13:36:09 +02:00
this.type = type;
} else {
throw new Error(`A notification's type either has to be info, success, warning, danger. Not: ${type}`);
}
2015-06-09 13:36:09 +02:00
this.dismissAfter = dismissAfter;
}
}