【发布时间】:2020-07-03 22:53:59
【问题描述】:
我想调用从setInterval 函数内部的服务类实例调用的异步函数。
class async {
constructor(public service: Service){}
async doSomeAsyncTask(){
setInterval(await this.service.anotherAsyncTaskInTheServiceClass(),3000);
//want to call the inside of setInterval function repeatedly in every 3ms.
}
}
}
【问题讨论】:
-
不是因为this关键字吗?我猜不需要指定它
-
那么你正在执行函数,而不是分配它,你为什么要使用 await?
标签: javascript typescript setinterval