wishthis/node_modules/rxjs/dist/esm/internal/observable/fromEventPattern.js
2022-04-07 09:06:43 +02:00

14 lines
No EOL
680 B
JavaScript

import { Observable } from '../Observable';
import { isFunction } from '../util/isFunction';
import { mapOneOrManyArgs } from '../util/mapOneOrManyArgs';
export function fromEventPattern(addHandler, removeHandler, resultSelector) {
if (resultSelector) {
return fromEventPattern(addHandler, removeHandler).pipe(mapOneOrManyArgs(resultSelector));
}
return new Observable((subscriber) => {
const handler = (...e) => subscriber.next(e.length === 1 ? e[0] : e);
const retValue = addHandler(handler);
return isFunction(removeHandler) ? () => removeHandler(handler, retValue) : undefined;
});
}
//# sourceMappingURL=fromEventPattern.js.map