小编Sta*_*nko的帖子

打字稿,装饰异步功能

我正在尝试使用一些异步功能2装饰异步功能1。

例如

function func2(param) {
   return (target: any, propertyKey: string, descriptor: PropertyDescriptor) =>    {
   //make async operations and then return descriptor
}


@func2(param)
async function func1() {
    await .... //some async operation
    await .... //some async operation
}
Run Code Online (Sandbox Code Playgroud)

因此,主要思想是在装饰器中执行一些异步操作,然后在main函数中执行其他异步调用。

可以使用打字稿装饰器来制作吗?

先感谢您。

decorator async-await typescript ecmascript-6

3
推荐指数
1
解决办法
2396
查看次数

标签 统计

async-await ×1

decorator ×1

ecmascript-6 ×1

typescript ×1