This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/rxjs/_esm5/internal/observable/fromEventPattern.js

33 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
/** PURE_IMPORTS_START _Observable,_util_isArray,_util_isFunction,_operators_map PURE_IMPORTS_END */
import { Observable } from '../Observable';
import { isArray } from '../util/isArray';
import { isFunction } from '../util/isFunction';
import { map } from '../operators/map';
export function fromEventPattern(addHandler, removeHandler, resultSelector) {
if (resultSelector) {
return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
}
return new Observable(function (subscriber) {
var handler = function () {
var e = [];
for (var _i = 0; _i < arguments.length; _i++) {
e[_i] = arguments[_i];
}
return subscriber.next(e.length === 1 ? e[0] : e);
};
var retValue;
try {
retValue = addHandler(handler);
}
catch (err) {
subscriber.error(err);
return undefined;
}
if (!isFunction(removeHandler)) {
return undefined;
}
return function () { return removeHandler(handler, retValue); };
});
}
//# sourceMappingURL=fromEventPattern.js.map