source: trip-planner-front/node_modules/rxjs/_esm5/internal/operators/withLatestFrom.js@ 8d391a1

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

initial commit

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/** PURE_IMPORTS_START tslib,_OuterSubscriber,_util_subscribeToResult PURE_IMPORTS_END */
2import * as tslib_1 from "tslib";
3import { OuterSubscriber } from '../OuterSubscriber';
4import { subscribeToResult } from '../util/subscribeToResult';
5export function withLatestFrom() {
6 var args = [];
7 for (var _i = 0; _i < arguments.length; _i++) {
8 args[_i] = arguments[_i];
9 }
10 return function (source) {
11 var project;
12 if (typeof args[args.length - 1] === 'function') {
13 project = args.pop();
14 }
15 var observables = args;
16 return source.lift(new WithLatestFromOperator(observables, project));
17 };
18}
19var WithLatestFromOperator = /*@__PURE__*/ (function () {
20 function WithLatestFromOperator(observables, project) {
21 this.observables = observables;
22 this.project = project;
23 }
24 WithLatestFromOperator.prototype.call = function (subscriber, source) {
25 return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
26 };
27 return WithLatestFromOperator;
28}());
29var WithLatestFromSubscriber = /*@__PURE__*/ (function (_super) {
30 tslib_1.__extends(WithLatestFromSubscriber, _super);
31 function WithLatestFromSubscriber(destination, observables, project) {
32 var _this = _super.call(this, destination) || this;
33 _this.observables = observables;
34 _this.project = project;
35 _this.toRespond = [];
36 var len = observables.length;
37 _this.values = new Array(len);
38 for (var i = 0; i < len; i++) {
39 _this.toRespond.push(i);
40 }
41 for (var i = 0; i < len; i++) {
42 var observable = observables[i];
43 _this.add(subscribeToResult(_this, observable, undefined, i));
44 }
45 return _this;
46 }
47 WithLatestFromSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
48 this.values[outerIndex] = innerValue;
49 var toRespond = this.toRespond;
50 if (toRespond.length > 0) {
51 var found = toRespond.indexOf(outerIndex);
52 if (found !== -1) {
53 toRespond.splice(found, 1);
54 }
55 }
56 };
57 WithLatestFromSubscriber.prototype.notifyComplete = function () {
58 };
59 WithLatestFromSubscriber.prototype._next = function (value) {
60 if (this.toRespond.length === 0) {
61 var args = [value].concat(this.values);
62 if (this.project) {
63 this._tryProject(args);
64 }
65 else {
66 this.destination.next(args);
67 }
68 }
69 };
70 WithLatestFromSubscriber.prototype._tryProject = function (args) {
71 var result;
72 try {
73 result = this.project.apply(this, args);
74 }
75 catch (err) {
76 this.destination.error(err);
77 return;
78 }
79 this.destination.next(result);
80 };
81 return WithLatestFromSubscriber;
82}(OuterSubscriber));
83//# sourceMappingURL=withLatestFrom.js.map
Note: See TracBrowser for help on using the repository browser.