File tree Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change 1
1
import { isFunction } from './util/isFunction' ;
2
- import { tryCatch } from './util/tryCatch' ;
3
- import { errorObject } from './util/errorObject' ;
4
-
5
2
import { Observer } from './Observer' ;
6
3
import { Subscription } from './Subscription' ;
7
4
import { rxSubscriber } from './symbol/rxSubscriber' ;
@@ -123,20 +120,23 @@ class SafeSubscriber<T> extends Subscriber<T> {
123
120
124
121
next ( value ?: T ) : void {
125
122
if ( ! this . isStopped && this . _next ) {
126
- if ( tryCatch ( this . _next ) . call ( this . _context , value ) === errorObject ) {
127
- this . unsubscribe ( ) ;
128
- throw errorObject . e ;
129
- }
123
+ this . __tryOrUnsub ( this . _next , value ) ;
124
+ }
125
+ }
126
+
127
+ __tryOrUnsub ( fn : Function , value ?: any ) : void {
128
+ try {
129
+ fn . call ( this . _context , value ) ;
130
+ } catch ( err ) {
131
+ this . unsubscribe ( ) ;
132
+ throw err ;
130
133
}
131
134
}
132
135
133
136
error ( err ?: any ) : void {
134
137
if ( ! this . isStopped ) {
135
138
if ( this . _error ) {
136
- if ( tryCatch ( this . _error ) . call ( this . _context , err ) === errorObject ) {
137
- this . unsubscribe ( ) ;
138
- throw errorObject . e ;
139
- }
139
+ this . __tryOrUnsub ( this . _error , err ) ;
140
140
}
141
141
this . unsubscribe ( ) ;
142
142
}
@@ -145,10 +145,7 @@ class SafeSubscriber<T> extends Subscriber<T> {
145
145
complete ( ) : void {
146
146
if ( ! this . isStopped ) {
147
147
if ( this . _complete ) {
148
- if ( tryCatch ( this . _complete ) . call ( this . _context ) === errorObject ) {
149
- this . unsubscribe ( ) ;
150
- throw errorObject . e ;
151
- }
148
+ this . __tryOrUnsub ( this . _complete ) ;
152
149
}
153
150
this . unsubscribe ( ) ;
154
151
}
@@ -160,4 +157,4 @@ class SafeSubscriber<T> extends Subscriber<T> {
160
157
this . _parent = null ;
161
158
_parent . unsubscribe ( ) ;
162
159
}
163
- }
160
+ }
You can’t perform that action at this time.
0 commit comments