source: trip-planner-front/node_modules/rxjs/internal/operators/withLatestFrom.js@ 6c1585f

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

initial commit

  • Property mode set to 100644
File size: 3.5 KB
Line 
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var OuterSubscriber_1 = require("../OuterSubscriber");
17var subscribeToResult_1 = require("../util/subscribeToResult");
18function withLatestFrom() {
19 var args = [];
20 for (var _i = 0; _i < arguments.length; _i++) {
21 args[_i] = arguments[_i];
22 }
23 return function (source) {
24 var project;
25 if (typeof args[args.length - 1] === 'function') {
26 project = args.pop();
27 }
28 var observables = args;
29 return source.lift(new WithLatestFromOperator(observables, project));
30 };
31}
32exports.withLatestFrom = withLatestFrom;
33var WithLatestFromOperator = (function () {
34 function WithLatestFromOperator(observables, project) {
35 this.observables = observables;
36 this.project = project;
37 }
38 WithLatestFromOperator.prototype.call = function (subscriber, source) {
39 return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
40 };
41 return WithLatestFromOperator;
42}());
43var WithLatestFromSubscriber = (function (_super) {
44 __extends(WithLatestFromSubscriber, _super);
45 function WithLatestFromSubscriber(destination, observables, project) {
46 var _this = _super.call(this, destination) || this;
47 _this.observables = observables;
48 _this.project = project;
49 _this.toRespond = [];
50 var len = observables.length;
51 _this.values = new Array(len);
52 for (var i = 0; i < len; i++) {
53 _this.toRespond.push(i);
54 }
55 for (var i = 0; i < len; i++) {
56 var observable = observables[i];
57 _this.add(subscribeToResult_1.subscribeToResult(_this, observable, undefined, i));
58 }
59 return _this;
60 }
61 WithLatestFromSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
62 this.values[outerIndex] = innerValue;
63 var toRespond = this.toRespond;
64 if (toRespond.length > 0) {
65 var found = toRespond.indexOf(outerIndex);
66 if (found !== -1) {
67 toRespond.splice(found, 1);
68 }
69 }
70 };
71 WithLatestFromSubscriber.prototype.notifyComplete = function () {
72 };
73 WithLatestFromSubscriber.prototype._next = function (value) {
74 if (this.toRespond.length === 0) {
75 var args = [value].concat(this.values);
76 if (this.project) {
77 this._tryProject(args);
78 }
79 else {
80 this.destination.next(args);
81 }
82 }
83 };
84 WithLatestFromSubscriber.prototype._tryProject = function (args) {
85 var result;
86 try {
87 result = this.project.apply(this, args);
88 }
89 catch (err) {
90 this.destination.error(err);
91 return;
92 }
93 this.destination.next(result);
94 };
95 return WithLatestFromSubscriber;
96}(OuterSubscriber_1.OuterSubscriber));
97//# sourceMappingURL=withLatestFrom.js.map
Note: See TracBrowser for help on using the repository browser.