fromEventPattern.js 1.0 KB

123456789101112131415161718192021222324
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.fromEventPattern = void 0;
  4. var Observable_1 = require("../Observable");
  5. var isFunction_1 = require("../util/isFunction");
  6. var mapOneOrManyArgs_1 = require("../util/mapOneOrManyArgs");
  7. function fromEventPattern(addHandler, removeHandler, resultSelector) {
  8. if (resultSelector) {
  9. return fromEventPattern(addHandler, removeHandler).pipe(mapOneOrManyArgs_1.mapOneOrManyArgs(resultSelector));
  10. }
  11. return new Observable_1.Observable(function (subscriber) {
  12. var handler = function () {
  13. var e = [];
  14. for (var _i = 0; _i < arguments.length; _i++) {
  15. e[_i] = arguments[_i];
  16. }
  17. return subscriber.next(e.length === 1 ? e[0] : e);
  18. };
  19. var retValue = addHandler(handler);
  20. return isFunction_1.isFunction(removeHandler) ? function () { return removeHandler(handler, retValue); } : undefined;
  21. });
  22. }
  23. exports.fromEventPattern = fromEventPattern;
  24. //# sourceMappingURL=fromEventPattern.js.map