1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00
onion/js/models/global_notification_model.js

22 lines
636 B
JavaScript
Raw Normal View History

'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) {
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
}
this.dismissAfter = dismissAfter;
this.type = type;
}
}