[ES7] Descorator: evaluated & call order
amp call order ES7
2023-09-14 08:59:19 时间
When multiple decorators apply to a single declaration, their evaluation is similar to function composition in mathematics. 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:
- The expressions for each decorator are evaluated top-to-bottom.
- The results are then called as functions from bottom-to-top.
If we were to use decorator factories, 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(): evaluated g(): evaluated g(): called f(): called */
相关文章
- 特征融合 & FFM(Feature Fusion Module) 特征融合模块
- 论文讨论&&思考《Deformable Convolutional Networks》
- AQS-semaphore&CyclicBarrier&CountDownLatch源码学习
- 7 Papers & Radios | 扩散模型只用文字PS照片;MIT泊松流生成模型击败扩散模型
- 约数个数定理&约数和定理
- Live Wallpaper & Themes 4K Pro for Mac(超高清4K动态壁纸)v15.7中文激活版
- App Cleaner & Uninstaller for mac(卸载程序和清理助手)
- 【React】组件&事件
- AMP:Google 的新开源项目能让网页秒开
- AMP MySQL升级提升数据库性能的必要之举(amp mysql升级)
- 如何增加Oracle数据库的AMP值(amp值oracle)
- MySQL 中使用 CALL 语句调用存储过程的方法概述(mysql 下call的)
- Oracle Call开启全新的数据库世界(oracle call是)
- javascript&&和||运算法的另类使用技巧
- Oracle中插入特殊字符:&和'的解决方法汇总