[ES7] Descorator: evaluated & call order
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 */
[ES7] Descorator: evaluated & call order的更多相关文章
- Fedora 24中的日志管理
Introduction Log files are files that contain messages about the system, including the kernel, servi ...
- SH Script Grammar
http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...
- bash内部命令-2
http://www.gnu.org/software/bash/ http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/ [root@250-shiyan ~]# ...
- [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 ...
- zonghe
package hcxAction; import hcxMode.Advertises; import hcxMode.Areas; import hcxMode.Saveresume; imp ...
- Load PE from memory(反取证)(未完)
Article 1:Loading Win32/64 DLLs "manually" without LoadLibrary() The most important step ...
- Bash基本功能
bash的基本功能 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 欢迎加入: 高级运维工程师之路 598432640 一.历史命令和命令补全 1.历 ...
- 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 ...
- Zipline Beginner Tutorial
Zipline Beginner Tutorial Basics Zipline is an open-source algorithmic trading simulator written in ...
随机推荐
- Js 中json简单处理
Json2.js下载地址 json常用处理 Json字符串 var str = '{"code":10,"msg":"codemsg",&q ...
- shell脚本学习积累笔记(第一篇)
(1)首先,今天在执行shell脚本./test.sh时抛出“/bin/sh^M: bad interpreter: No such file or directory”的异常,百度后,才知道这是由于 ...
- Codeforces Round #316 div2
一场充满血腥hack之战!!! Problem_A: 题意: n个候选人在m个城市进行投票,每个城市选出票数最多的一个候选人为城市候选人,如果票数相同,则取编号小的候选人. 再从这m个城市候选人中选出 ...
- What does it mean for an algorithm to be fair
What does it mean for an algorithm to be fair In 2014 the White House commissioned a 90-day study th ...
- Codeforces Round #198 (Div. 2) —— A
最水的题,可惜当时赶时间没有注意数据范围:暴力超时了! 其实应该用x,y的最大公约数来判断: 代码: #include<iostream> using namespace std; int ...
- Android学习及如何利用android来赚钱
一.如何学习Android android开发(这里不提platform和底层驱动)你需要对Java有个良好的基础,一般我们用Eclipse作为开发工具.对于过多的具体知识详细介绍我这里不展 ...
- ANDROID_MARS学习笔记_S03_008_GOOGLEMAP2
一.简介 二.代码1.xml(1)main.xml <?xml version="1.0" encoding="utf-8"?> <Linea ...
- 【HDOJ】4553 约会安排
线段树.线段树的细节很重要,小数据遍历可以发现问题. /* 4553 */ #include <iostream> #include <string> #include < ...
- ThreadPoolExecutor原理及使用
大家先从ThreadPoolExecutor的总体流程入手: 针对ThreadPoolExecutor代码,我们来看下execute方法: public void execute(Runnable c ...
- SQL Server select into用法
作用: SELECT INTO 语句从一个表中选取数据,然后把数据插入另一个表中. SELECT INTO 语句常用于创建表的备份复件或者用于对记录进行存档 这个语句会在数据库中用和你所指定的列类型和 ...