Angular2 - rxjs观察vs处置?

Angular2 - rxjs观察vs处置?

问题描述:

取消订阅和处理有什么区别?Angular2 - rxjs观察vs处置?

例如

// app-service.ts 
{Http} from @angular/core; 

export class appService { 
    constructor(private http : Http, fooService : FooService) {} 
    getAll() { 
     // do this 
     this.sub = this.fooService.subscribe(
      () => {}, 
      error => throw new Error(error), 
      () => {} 
     ) 
    } 

    ngOnDestroy() { 
     this.sub.dispose(); 
    } 
} 

它是rxjs4 - rxjs5差;

rxjs4Disposable是你们等dispose(),现在他们Subscription是你们等unsubscribe()

来源:https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md