|
1234567891011121314151617181920212223242526272829303132 |
- /** 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
|