今天有个需求,要求前端有个心跳机制,每十秒访问一个指定接口,想到权威指南里一直有提过setTimeout好于setInterval,就磨刀霍霍向代码了。
第一版 为了测试,时间改为1秒了
t_:number;
const that = this;
setTimeout(function test(){
that.http.query('/api/heart_beat', {
}).subscribe(res => {
今天有个需求,要求前端有个心跳机制,每十秒访问一个指定接口,想到权威指南里一直有提过setTimeout好于setInterval,就磨刀霍霍向代码了。
第一版 为了测试,时间改为1秒了
t_:number;
const that = this;
setTimeout(function test(){
that.http.query('/api/heart_beat', {
}).subscribe(res => {