Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | var Observable_1 = require("../Observable");
|
---|
4 | var isArray_1 = require("../util/isArray");
|
---|
5 | var isFunction_1 = require("../util/isFunction");
|
---|
6 | var map_1 = require("../operators/map");
|
---|
7 | function fromEventPattern(addHandler, removeHandler, resultSelector) {
|
---|
8 | if (resultSelector) {
|
---|
9 | return fromEventPattern(addHandler, removeHandler).pipe(map_1.map(function (args) { return isArray_1.isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
|
---|
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;
|
---|
20 | try {
|
---|
21 | retValue = addHandler(handler);
|
---|
22 | }
|
---|
23 | catch (err) {
|
---|
24 | subscriber.error(err);
|
---|
25 | return undefined;
|
---|
26 | }
|
---|
27 | if (!isFunction_1.isFunction(removeHandler)) {
|
---|
28 | return undefined;
|
---|
29 | }
|
---|
30 | return function () { return removeHandler(handler, retValue); };
|
---|
31 | });
|
---|
32 | }
|
---|
33 | exports.fromEventPattern = fromEventPattern;
|
---|
34 | //# sourceMappingURL=fromEventPattern.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.