source: trip-planner-front/node_modules/rxjs/_esm5/internal/observable/bindCallback.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/** PURE_IMPORTS_START _Observable,_AsyncSubject,_operators_map,_util_canReportError,_util_isArray,_util_isScheduler PURE_IMPORTS_END */
2import { Observable } from '../Observable';
3import { AsyncSubject } from '../AsyncSubject';
4import { map } from '../operators/map';
5import { canReportError } from '../util/canReportError';
6import { isArray } from '../util/isArray';
7import { isScheduler } from '../util/isScheduler';
8export function bindCallback(callbackFunc, resultSelector, scheduler) {
9 if (resultSelector) {
10 if (isScheduler(resultSelector)) {
11 scheduler = resultSelector;
12 }
13 else {
14 return function () {
15 var args = [];
16 for (var _i = 0; _i < arguments.length; _i++) {
17 args[_i] = arguments[_i];
18 }
19 return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
20 };
21 }
22 }
23 return function () {
24 var args = [];
25 for (var _i = 0; _i < arguments.length; _i++) {
26 args[_i] = arguments[_i];
27 }
28 var context = this;
29 var subject;
30 var params = {
31 context: context,
32 subject: subject,
33 callbackFunc: callbackFunc,
34 scheduler: scheduler,
35 };
36 return new Observable(function (subscriber) {
37 if (!scheduler) {
38 if (!subject) {
39 subject = new AsyncSubject();
40 var handler = function () {
41 var innerArgs = [];
42 for (var _i = 0; _i < arguments.length; _i++) {
43 innerArgs[_i] = arguments[_i];
44 }
45 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
46 subject.complete();
47 };
48 try {
49 callbackFunc.apply(context, args.concat([handler]));
50 }
51 catch (err) {
52 if (canReportError(subject)) {
53 subject.error(err);
54 }
55 else {
56 console.warn(err);
57 }
58 }
59 }
60 return subject.subscribe(subscriber);
61 }
62 else {
63 var state = {
64 args: args, subscriber: subscriber, params: params,
65 };
66 return scheduler.schedule(dispatch, 0, state);
67 }
68 });
69 };
70}
71function dispatch(state) {
72 var _this = this;
73 var self = this;
74 var args = state.args, subscriber = state.subscriber, params = state.params;
75 var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
76 var subject = params.subject;
77 if (!subject) {
78 subject = params.subject = new AsyncSubject();
79 var handler = function () {
80 var innerArgs = [];
81 for (var _i = 0; _i < arguments.length; _i++) {
82 innerArgs[_i] = arguments[_i];
83 }
84 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
85 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
86 };
87 try {
88 callbackFunc.apply(context, args.concat([handler]));
89 }
90 catch (err) {
91 subject.error(err);
92 }
93 }
94 this.add(subject.subscribe(subscriber));
95}
96function dispatchNext(state) {
97 var value = state.value, subject = state.subject;
98 subject.next(value);
99 subject.complete();
100}
101function dispatchError(state) {
102 var err = state.err, subject = state.subject;
103 subject.error(err);
104}
105//# sourceMappingURL=bindCallback.js.map
Note: See TracBrowser for help on using the repository browser.