|
1 | 1 | import {Operator} from '../Operator';
|
2 | 2 | import {Subscriber} from '../Subscriber';
|
3 | 3 | import {Observable} from '../Observable';
|
4 |
| -import {tryCatch} from '../util/tryCatch'; |
5 |
| -import {errorObject} from '../util/errorObject'; |
6 | 4 | import {OuterSubscriber} from '../OuterSubscriber';
|
7 | 5 | import {subscribeToResult} from '../util/subscribeToResult';
|
8 | 6 |
|
@@ -81,20 +79,23 @@ class WithLatestFromSubscriber<T, R> extends OuterSubscriber<T, R> {
|
81 | 79 |
|
82 | 80 | protected _next(value: T) {
|
83 | 81 | if (this.toRespond.length === 0) {
|
84 |
| - const values = this.values; |
85 |
| - const destination = this.destination; |
86 |
| - const project = this.project; |
87 |
| - const args = [value, ...values]; |
88 |
| - if (project) { |
89 |
| - let result = tryCatch(this.project).apply(this, args); |
90 |
| - if (result === errorObject) { |
91 |
| - destination.error(result.e); |
92 |
| - } else { |
93 |
| - destination.next(result); |
94 |
| - } |
| 82 | + const args = [value, ...this.values]; |
| 83 | + if (this.project) { |
| 84 | + this._tryProject(args); |
95 | 85 | } else {
|
96 |
| - destination.next(args); |
| 86 | + this.destination.next(args); |
97 | 87 | }
|
98 | 88 | }
|
99 | 89 | }
|
| 90 | + |
| 91 | + private _tryProject(args: any[]) { |
| 92 | + let result: any; |
| 93 | + try { |
| 94 | + result = this.project.apply(this, args); |
| 95 | + } catch (err) { |
| 96 | + this.destination.error(err); |
| 97 | + return; |
| 98 | + } |
| 99 | + this.destination.next(result); |
| 100 | + } |
100 | 101 | }
|
0 commit comments