UNPKG

@absinthe/socket

Version:
54 lines (36 loc) 1.58 kB
'use strict'; function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var utilsArray = require('@jumpn/utils-array'); require('core-js/modules/es6.array.find-index'); var utilsComposite = require('@jumpn/utils-composite'); require('core-js/modules/es6.function.bind'); var _newArrowCheck = _interopDefault(require('@babel/runtime/helpers/newArrowCheck')); var _this = undefined; var findIndex = function findIndex(notifiers, key, value // $FlowFixMe: flow is having some troubles to match hasIn signature (curry) ) { _newArrowCheck(this, _this); return notifiers.findIndex(utilsComposite.hasIn([key], value)); }.bind(undefined); var _this$1 = undefined; var refresh = function refresh(notifier) { var _this2 = this; _newArrowCheck(this, _this$1); return function (notifiers) { _newArrowCheck(this, _this2); return utilsArray.replace(findIndex(notifiers, "request", notifier.request), [notifier], notifiers); }.bind(this); }.bind(undefined); var _this$2 = undefined; var updateNotifiers = function updateNotifiers(absintheSocket, updater) { _newArrowCheck(this, _this$2); absintheSocket.notifiers = updater(absintheSocket.notifiers); return absintheSocket; }.bind(undefined); var _this$3 = undefined; var refreshNotifier = function refreshNotifier(absintheSocket, notifier) { _newArrowCheck(this, _this$3); updateNotifiers(absintheSocket, refresh(notifier)); return notifier; }.bind(undefined); module.exports = refreshNotifier; //# sourceMappingURL=refreshNotifier.js.map