UNPKG

mobx-toastr

Version:

Tiny Mobx wrapper around Toastr notifications library.

141 lines (116 loc) 4.23 kB
'use strict'; function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var mobx = require('mobx'); var toastr = _interopDefault(require('toastr')); var classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7; function _initDefineProp(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object['ke' + 'ys'](descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object['define' + 'Property'](target, property, desc); desc = null; } return desc; } var Toastr = (_class = function Toastr() { var optionsOverride = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; classCallCheck(this, Toastr); _initDefineProp(this, 'message', _descriptor, this); _initDefineProp(this, 'success', _descriptor2, this); _initDefineProp(this, 'error', _descriptor3, this); _initDefineProp(this, 'warning', _descriptor4, this); _initDefineProp(this, 'info', _descriptor5, this); _initDefineProp(this, 'clear', _descriptor6, this); _initDefineProp(this, 'remove', _descriptor7, this); toastr.options = _extends({}, optionsOverride); }, (_descriptor = _applyDecoratedDescriptor(_class.prototype, 'message', [mobx.action], { enumerable: true, initializer: function initializer() { return function (title, message, type) { toastr[type](message, title); }; } }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, 'success', [mobx.action], { enumerable: true, initializer: function initializer() { return function (title, message) { toastr.success(title, message); }; } }), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, 'error', [mobx.action], { enumerable: true, initializer: function initializer() { return function (title, message) { toastr.error(title, message); }; } }), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, 'warning', [mobx.action], { enumerable: true, initializer: function initializer() { return function (title, message) { toastr.warning(title, message); }; } }), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, 'info', [mobx.action], { enumerable: true, initializer: function initializer() { return function (title, message) { toastr.info(title, message); }; } }), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, 'clear', [mobx.action], { enumerable: true, initializer: function initializer() { return function () { toastr.clear(); }; } }), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, 'remove', [mobx.action], { enumerable: true, initializer: function initializer() { return function () { toastr.remove(); }; } })), _class); module.exports = Toastr; //# sourceMappingURL=index.js.map