博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[ES7] Descorator: evaluated & call order
阅读量:7051 次
发布时间:2019-06-28

本文共 966 字,大约阅读时间需要 3 分钟。

When multiple decorators apply to a single declaration, their evaluation is similar to . In this model, when composing functions f and g, the resulting composite (f ∘ g)(x) is equivalent to f(g(x)).

As such, the following steps are performed when evaluating multiple decorators on a single declaration in TypeScript:

  1. The expressions for each decorator are evaluated top-to-bottom.
  2. The results are then called as functions from bottom-to-top.

If we were to use , we can observe this evaluation order with the following example:

function f() {    console.log("f(): evaluated");    return function (target, propertyKey: string, descriptor: PropertyDescriptor) {        console.log("f(): called");    }}function g() {    console.log("g(): evaluated");    return function (target, propertyKey: string, descriptor: PropertyDescriptor) {        console.log("g(): called");    }}class C {    @f()    @g()    method() {}}/*f(): evaluatedg(): evaluatedg(): calledf(): called*/

 

转载地址:http://mkpol.baihongyu.com/

你可能感兴趣的文章
mysql优化sql语句查询的方法(一)
查看>>
既然存在,就是合理的
查看>>
【GIT-1】GIT 的基础教程 创建,添加,更替,追溯版本库
查看>>
【原创】公司自研缓存系统UPU的总结
查看>>
一个JavaScript的简单通用验证
查看>>
java面试基本数据类型考点
查看>>
百行 HTML5 代码实现四种双人对弈游戏
查看>>
jQuery.extend 函数详解
查看>>
phpstorm 安装 及 使用 去掉名称类型提示
查看>>
Xp sp3 创建进程的堆栈
查看>>
Log4j的扩展-支持设置最大日志数量的DailyRollingFileAppender
查看>>
IT行业¬——Linux
查看>>
linkerd ab部署测试
查看>>
#日常杂记#Informatica 910 常见问题及可能的解决方法
查看>>
Spring Cloud Gateway 之 Only one connection receive subscriber allowed
查看>>
VoltDB 简介
查看>>
编译日志
查看>>
FieldType in Lucene
查看>>
为面试准备的知识点
查看>>
使用 CXF 做 webservice 简单例子
查看>>