Angular2 - rxjs观察与处置?

chr*_*lee 1 rxjs angular

取消订阅和处置之间的区别是什么?

例如

// 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();
   }
}
Run Code Online (Sandbox Code Playgroud)

eko*_*eko 6

这是一个rxjs4- rxjs5差异;

rxjs4那里,Disposable有你dispose(),现在他们是Subscriptionunsubscribe()

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