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.2 KB
|
Line | |
---|
1 | /** PURE_IMPORTS_START _Observable,_util_isArray,_util_isFunction,_operators_map PURE_IMPORTS_END */
|
---|
2 | import { Observable } from '../Observable';
|
---|
3 | import { isArray } from '../util/isArray';
|
---|
4 | import { isFunction } from '../util/isFunction';
|
---|
5 | import { map } from '../operators/map';
|
---|
6 | export function fromEventPattern(addHandler, removeHandler, resultSelector) {
|
---|
7 | if (resultSelector) {
|
---|
8 | return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
|
---|
9 | }
|
---|
10 | return new Observable(function (subscriber) {
|
---|
11 | var handler = function () {
|
---|
12 | var e = [];
|
---|
13 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
14 | e[_i] = arguments[_i];
|
---|
15 | }
|
---|
16 | return subscriber.next(e.length === 1 ? e[0] : e);
|
---|
17 | };
|
---|
18 | var retValue;
|
---|
19 | try {
|
---|
20 | retValue = addHandler(handler);
|
---|
21 | }
|
---|
22 | catch (err) {
|
---|
23 | subscriber.error(err);
|
---|
24 | return undefined;
|
---|
25 | }
|
---|
26 | if (!isFunction(removeHandler)) {
|
---|
27 | return undefined;
|
---|
28 | }
|
---|
29 | return function () { return removeHandler(handler, retValue); };
|
---|
30 | });
|
---|
31 | }
|
---|
32 | //# sourceMappingURL=fromEventPattern.js.map
|
---|
Note:
See
TracBrowser
for help on using the repository browser.