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:

  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 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 */

[ES7] Descorator: evaluated & call order的更多相关文章

  1. Fedora 24中的日志管理

    Introduction Log files are files that contain messages about the system, including the kernel, servi ...

  2. SH Script Grammar

    http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...

  3. bash内部命令-2

    http://www.gnu.org/software/bash/ http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/ [root@250-shiyan ~]# ...

  4. [Hive - LanguageManual] Create/Drop/Alter -View、 Index 、 Function

    Create/Drop/Alter View Create View Drop View Alter View Properties Alter View As Select Version info ...

  5. zonghe

      package hcxAction; import hcxMode.Advertises; import hcxMode.Areas; import hcxMode.Saveresume; imp ...

  6. Load PE from memory(反取证)(未完)

      Article 1:Loading Win32/64 DLLs "manually" without LoadLibrary() The most important step ...

  7. Bash基本功能

    bash的基本功能 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 欢迎加入:   高级运维工程师之路               598432640 一.历史命令和命令补全 1.历 ...

  8. MemoryModule -- load a DLL completely from memory

    https://github.com/fancycode/MemoryModule MemoryModule is a library that can be used to load a DLL c ...

  9. Zipline Beginner Tutorial

    Zipline Beginner Tutorial Basics Zipline is an open-source algorithmic trading simulator written in ...

随机推荐

  1. MINA源码阅读之ACP

    Processor在XXAcceptor以及XXConnector中所扮演的只能就是:作为Acceptor以及Connetor所创建的Session的Processor: IoAcceptor作为他所 ...

  2. SNA社交网络算法

    社交网络需要用到igraph库,所以需要安装.可以在lfd的网站 http://www.lfd.uci.edu/~gohlke/pythonlibs/ 上下载python_igraph,具体的pyth ...

  3. 发布FireBird数据库所需要DLL文件

    数据库版本:2.5.2 ib_util.dll; icudt30.dll; icuin30.dll icuuc30.dll

  4. #include<filename.h> 与 #include“filename.h”

    #include<filename.h>:从标准库路径去寻找该文件,对于VC来说,应该还包括VC环境设置选项中的包含目录以及工程属性中指定的目录. #include“filename.h” ...

  5. bzoj 3435: [Wc2014]紫荆花之恋 替罪羊树维护点分治 && AC400

    3435: [Wc2014]紫荆花之恋 Time Limit: 240 Sec  Memory Limit: 512 MBSubmit: 159  Solved: 40[Submit][Status] ...

  6. BZOJ 1668: [Usaco2006 Oct]Cow Pie Treasures 馅饼里的财富

    Description 最近,奶牛们热衷于把金币包在面粉里,然后把它们烤成馅饼.第i块馅饼中含有Ni(1<=Ni<=25)块金币,并且,这个数字被醒目地标记在馅饼表面. 奶牛们把所有烤好的 ...

  7. 在HTML下,如何为多个选择框提取数据并序列化

    如果同时存在选择框及下拉框,如果用JQUERY获取相关数据呢? <form id="deploy-form"> <checkbox>多选框 <sele ...

  8. 一种Android换肤机制的实现

    http://eastmoneyandroid.github.io/2016/01/22/android-reskin/

  9. Legal or Not

    Legal or Not Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total ...

  10. extjs form 取值 赋值 重置

    一.从form中获取field的三个方法: 1.Ext.getCmp('id'); 2.FormPanel.getForm().findField('id/name'); 3.Ext.get('id/ ...