取消订阅和处置之间的区别是什么?
例如
// 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)
这是一个rxjs4- rxjs5差异;
在rxjs4那里,Disposable有你dispose(),现在他们是Subscription你unsubscribe()
资料来源:https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md
| 归档时间: |
|
| 查看次数: |
210 次 |
| 最近记录: |