File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -810,6 +810,24 @@ describe('Observable', () => {
810
810
} ) . not . to . throw ( ) ;
811
811
} ) ;
812
812
813
+ it ( 'should call teardown if sync unsubscribed' , ( ) => {
814
+ let called = false ;
815
+ const observable = new Observable ( ( ) => ( ) => ( called = true ) ) ;
816
+ const subscription = observable . subscribe ( ) ;
817
+ subscription . unsubscribe ( ) ;
818
+
819
+ expect ( called ) . to . be . true ;
820
+ } ) ;
821
+
822
+ it ( 'should call registered teardowns if sync unsubscribed' , ( ) => {
823
+ let called = false ;
824
+ const observable = new Observable ( ( subscriber ) => subscriber . add ( ( ) => called = true ) ) ;
825
+ const subscription = observable . subscribe ( ) ;
826
+ subscription . unsubscribe ( ) ;
827
+
828
+ expect ( called ) . to . be . true ;
829
+ } ) ;
830
+
813
831
afterEach ( ( ) => {
814
832
config . useDeprecatedSynchronousErrorHandling = false ;
815
833
} ) ;
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ export class Observable<T> implements Subscribable<T> {
252
252
subscriber . add ( operator . call ( subscriber , this . source ) ) ;
253
253
} else {
254
254
try {
255
- this . _subscribe ( subscriber ) ;
255
+ subscriber . add ( this . _subscribe ( subscriber ) ) ;
256
256
} catch ( err ) {
257
257
localSubscriber . __syncError = err ;
258
258
}
You can’t perform that action at this time.
0 commit comments