【发布时间】:2019-11-16 01:36:54
【问题描述】:
我正在尝试编写一些方法装饰器以在 typescript 中与 firebase 函数一起使用,但我对语法有点困惑,而且到目前为止我尝试过的方法不起作用。
我想在我的类中有方法,例如:
@OnCall('europe-west1')
@Wrapper([errorHandler, validateSomething])
doSomething(data, context) {
// doing stuff in the function
}
最终的结果是:
const doSomething = functions.region(<REGION PARAM>).https.onCall((data, context) => {
errorHandler() {
validateSomething() {
DECORATEDFUNCTION()
}
});
现在包装部分虽然可取,但起初并不那么重要。到目前为止,我已经尝试了各种变体:
export function OnCall(region: string, name: string, target: any): MethodDecorator {
return target => {
//
};
}
【问题讨论】:
标签: typescript typescript-decorator