@absinthe/socket
Version:
60 lines (40 loc) • 1.7 kB
JavaScript
;
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var _toConsumableArray = _interopDefault(require('@babel/runtime/helpers/toConsumableArray'));
require('core-js/modules/web.dom.iterable');
require('core-js/modules/es6.array.for-each');
require('core-js/modules/es6.function.name');
require('core-js/modules/es6.function.bind');
var _newArrowCheck = _interopDefault(require('@babel/runtime/helpers/newArrowCheck'));
var _this = undefined;
var getNotifier = function getNotifier(handlerName, payload) {
var _this2 = this;
_newArrowCheck(this, _this);
return function (observer) {
_newArrowCheck(this, _this2);
return observer[handlerName] && observer[handlerName](payload);
}.bind(this);
}.bind(undefined);
var getHandlerName = function getHandlerName(_ref) {
var name = _ref.name;
_newArrowCheck(this, _this);
return "on".concat(name);
}.bind(undefined);
var notifyAll = function notifyAll(observers, event) {
_newArrowCheck(this, _this);
return observers.forEach(getNotifier(getHandlerName(event), event.payload));
}.bind(undefined);
var _this$1 = undefined;
var getObservers = function getObservers(_ref) {
var activeObservers = _ref.activeObservers,
canceledObservers = _ref.canceledObservers;
_newArrowCheck(this, _this$1);
return _toConsumableArray(activeObservers).concat(_toConsumableArray(canceledObservers));
}.bind(undefined);
var notify = function notify(notifier, event) {
_newArrowCheck(this, _this$1);
notifyAll(getObservers(notifier), event);
return notifier;
}.bind(undefined);
module.exports = notify;
//# sourceMappingURL=notify.js.map