File tree Expand file tree Collapse file tree 4 files changed +7
-25
lines changed Expand file tree Collapse file tree 4 files changed +7
-25
lines changed Original file line number Diff line number Diff line change 11import  {  expect  }  from  'chai' ; 
22import  {  SafeSubscriber  }  from  'rxjs/internal/Subscriber' ; 
33import  {  Subscriber  }  from  'rxjs' ; 
4- import  {  rxSubscriber  }  from  'rxjs/internal/symbol/rxSubscriber' ; 
54
65/** @test  {Subscriber} */ 
76describe ( 'Subscriber' ,  ( )  =>  { 
@@ -20,17 +19,6 @@ describe('Subscriber', () => {
2019    expect ( times ) . to . equal ( 2 ) ; 
2120  } ) ; 
2221
23-   it ( 'should accept subscribers as a destination if they meet the proper criteria' ,  ( )  =>  { 
24-     const  fakeSubscriber  =  { 
25-       [ rxSubscriber ] ( this : any )  {  return  this ;  } , 
26-       add ( )  {  /* noop */  } , 
27-       syncErrorThrowable : false 
28-     } ; 
29- 
30-     const  subscriber  =  new  Subscriber ( fakeSubscriber  as  any ) ; 
31-     expect ( ( subscriber  as  any ) . destination ) . to . equal ( fakeSubscriber ) ; 
32-   } ) ; 
33- 
3422  it ( 'should wrap unsafe observers in a safe subscriber' ,  ( )  =>  { 
3523    const  observer  =  { 
3624      next ( x : any )  {  /* noop */  } , 
Original file line number Diff line number Diff line change @@ -72,13 +72,10 @@ export class Subscriber<T> extends Subscription implements Observer<T> {
7272          break ; 
7373        } 
7474        if  ( typeof  destinationOrNext  ===  'object' )  { 
75-           // HACK(benlesh): For situations where Node has multiple copies of rxjs in 
76-           // node_modules, we cannot rely on `instanceof` checks 
77-           if  ( isTrustedSubscriber ( destinationOrNext ) )  { 
78-             const  trustedSubscriber  =  destinationOrNext [ rxSubscriberSymbol ] ( )  as  Subscriber < any > ; 
79-             this . syncErrorThrowable  =  trustedSubscriber . syncErrorThrowable ; 
80-             this . destination  =  trustedSubscriber ; 
81-             trustedSubscriber . add ( this ) ; 
75+           if  ( destinationOrNext  instanceof  Subscriber )  { 
76+             this . syncErrorThrowable  =  destinationOrNext . syncErrorThrowable ; 
77+             this . destination  =  destinationOrNext ; 
78+             destinationOrNext . add ( this ) ; 
8279          }  else  { 
8380            this . syncErrorThrowable  =  true ; 
8481            this . destination  =  new  SafeSubscriber < T > ( this ,  < PartialObserver < any > >  destinationOrNext ) ; 
@@ -308,7 +305,3 @@ export class SafeSubscriber<T> extends Subscriber<T> {
308305    _parentSubscriber . unsubscribe ( ) ; 
309306  } 
310307} 
311- 
312- export  function  isTrustedSubscriber ( obj : any )  { 
313-   return  obj  instanceof  Subscriber  ||  ( 'syncErrorThrowable'  in  obj  &&  obj [ rxSubscriberSymbol ] ) ; 
314- } 
Original file line number Diff line number Diff line change 1+ /** @deprecated  do not use, this is no longer checked by RxJS internals */ 
12export  const  rxSubscriber  = 
23  ( typeof  Symbol  ===  'function'  &&  typeof  Symbol . for  ===  'function' ) 
34    ? Symbol . for ( 'rxSubscriber' ) 
Original file line number Diff line number Diff line change 1- import  {  isTrustedSubscriber ,   Subscriber  }  from  '../Subscriber' ; 
1+ import  {  Subscriber  }  from  '../Subscriber' ; 
22import  {  Subject  }  from  '../Subject' ; 
33
44/** 
@@ -12,7 +12,7 @@ export function canReportError(observer: Subscriber<any> | Subject<any>): boolea
1212    const  {  closed,  destination,  isStopped }  =  observer  as  any ; 
1313    if  ( closed  ||  isStopped )  { 
1414      return  false ; 
15-     }  else  if  ( destination  &&  isTrustedSubscriber ( destination ) )  { 
15+     }  else  if  ( destination  &&  destination   instanceof   Subscriber )  { 
1616      observer  =  destination ; 
1717    }  else  { 
1818      observer  =  null ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments