@@ -3,8 +3,6 @@ import {Observer} from '../Observer';
3
3
import { Subscriber } from '../Subscriber' ;
4
4
5
5
import { noop } from '../util/noop' ;
6
- import { tryCatch } from '../util/tryCatch' ;
7
- import { errorObject } from '../util/errorObject' ;
8
6
import { Observable } from '../Observable' ;
9
7
10
8
/**
@@ -58,30 +56,35 @@ class DoSubscriber<T> extends Subscriber<T> {
58
56
this . __complete = complete ;
59
57
}
60
58
61
- protected _next ( x : T ) {
62
- const result = tryCatch ( this . __next ) ( x ) ;
63
- if ( result === errorObject ) {
64
- this . destination . error ( errorObject . e ) ;
65
- } else {
66
- this . destination . next ( x ) ;
59
+ // NOTE: important, all try catch blocks below are there for performance
60
+ // reasons. tryCatcher approach does not benefit this operator.
61
+ protected _next ( value : T ) {
62
+ try {
63
+ this . __next ( value ) ;
64
+ } catch ( err ) {
65
+ this . destination . error ( err ) ;
66
+ return ;
67
67
}
68
+ this . destination . next ( value ) ;
68
69
}
69
70
70
- protected _error ( e : any ) {
71
- const result = tryCatch ( this . __error ) ( e ) ;
72
- if ( result === errorObject ) {
73
- this . destination . error ( errorObject . e ) ;
74
- } else {
75
- this . destination . error ( e ) ;
71
+ protected _error ( err : any ) {
72
+ try {
73
+ this . __error ( err ) ;
74
+ } catch ( err ) {
75
+ this . destination . error ( err ) ;
76
+ return ;
76
77
}
78
+ this . destination . error ( err ) ;
77
79
}
78
80
79
81
protected _complete ( ) {
80
- const result = tryCatch ( this . __complete ) ( ) ;
81
- if ( result === errorObject ) {
82
- this . destination . error ( errorObject . e ) ;
83
- } else {
84
- this . destination . complete ( ) ;
82
+ try {
83
+ this . __complete ( ) ;
84
+ } catch ( err ) {
85
+ this . destination . error ( err ) ;
86
+ return ;
85
87
}
88
+ this . destination . complete ( ) ;
86
89
}
87
90
}
0 commit comments