我在几分钟后有超时模式,有时我需要将角度5中的时间重置clearInterval()
不起作用,所以我使用了可观察的计时器,但是unsubscribe()
或subject.next()
未重置时间。。。
export class TimeOutModalService extends ServiceBase {
subject: Subject<{}>;
timer: Observable<number>;
finished: boolean;
intervalObj = undefined;
constructor() {
super();
this.subject = new Subject();
}
create() {
this.timer = Observable.interval(10000);
this.intervalObj = this.timer.subscribe(() => {
this.callback();
});
};
callback() {
$('#time-out-modal #window-modal').modal({ backdrop: 'static', keyboard: false, show: true })
}
reset = () => {
if (this.intervalObj) {
this.intervalObj.unsubscribe();
}
this.create();
};
}