Repository URL to install this package:
|
Version:
0.0.6 ▾
|
import * as tslib_1 from "tslib";
/**
* @file @todo maybe should put most of this in the application container, or snackbar container
* ^ we need to be able to set actions (like `view cart` or `dismiss` or `undo`)
*/
import { observable, action } from 'xmobx/mobx';
/**
* @alias ErrorContainer
*/
class NotificationContainer {
constructor() {
this.isVisible = false;
this.errorMessage = '';
this.error = { errorMessage: '' };
}
get label() {
return this.errorMessage;
}
setError(error) {
this.error = error;
this.errorMessage = error.errorMessage;
this.isVisible = true;
}
resetError() {
this.error = { errorMessage: '' };
this.errorMessage = '';
this.isVisible = false;
}
setMessage(errorMessage) {
this.setError({ errorMessage });
}
notifyFor(key) {
this.setError({ errorMessage: key });
}
}
NotificationContainer.debugName = 'Error';
tslib_1.__decorate([
observable
], NotificationContainer.prototype, "isVisible", void 0);
tslib_1.__decorate([
observable
], NotificationContainer.prototype, "errorMessage", void 0);
tslib_1.__decorate([
observable
], NotificationContainer.prototype, "error", void 0);
tslib_1.__decorate([
action
], NotificationContainer.prototype, "setError", null);
tslib_1.__decorate([
action.bound
], NotificationContainer.prototype, "resetError", null);
tslib_1.__decorate([
action
], NotificationContainer.prototype, "setMessage", null);
tslib_1.__decorate([
action
], NotificationContainer.prototype, "notifyFor", null);
export { NotificationContainer };
export { NotificationContainer as ErrorContainer };
//# sourceMappingURL=NotificationContainer.js.map