我有以下可观察的倒数计算:
Observable.interval(1000).map((x) => {
let date1= Math.floor(new Date().getTime()/1000);
let date2 = Math.floor(this.future.getTime()/1000)+600;
this.diff = date2 - date1;
}).subscribe((x) => {
this.message = this.dhms(this.diff);
});
我希望在this.diff
< = 0时停止observable。(因为倒计时已完成)
我怎么能这样做?
答案 0 :(得分:3)
let sub = Observable.interval(1000).map((x) => {
...
sub.unsubsribe();