hugoWebsite/node_modules/rxjs/dist/esm/internal/observable/fromEventPattern.js

14 lines
680 B
JavaScript
Raw Normal View History

2022-10-29 00:20:35 +02:00
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