ES-Next @Decorator All In One

@装饰器

import { logged } from "./logged.mjs";

class C {
@logged
m(arg) {
this.#x = arg;
} @logged
set #x(value) { }
} new C().m(1);
// starting m with arguments 1
// starting set #x with arguments 1
// ending set #x
// ending m

https://github.com/tc39/proposal-decorators

https://tc39.es/proposal-decorators/

babel


https://babeljs.io/docs/en/babel-plugin-proposal-decorators

https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy

TypeScript @Decorator


TypeScript 4.0 / TypeScript 4.1 beta

https://www.typescriptlang.org/docs/handbook/decorators.html

TypeScript 3.1

https://www.tslang.cn/docs/handbook/decorators.html

bug

Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.

https://github.com/microsoft/TypeScript/issues/9335

https://github.com/microsoft/TypeScript/issues/8905

https://github.com/microsoft/TypeScript/pull/6881

https://github.com/microsoft/TypeScript/issues/6872

https://github.com/Microsoft/TypeScript/issues/25823

https://stackoverflow.com/questions/38271273/experimental-decorators-warning-in-typescript-compilation

Angular @Decorator


React @Decorator


HTML Custom Elements

import { defineElement } from "./defineElement.mjs";

@defineElement('my-class')
class MyClass extends HTMLElement { }

https://github.com/tc39/proposal-decorators#defineelement

https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements

vanilla js decorators

https://javascript.info/call-apply-decorators

let wrapper = function() {
return original.apply(this, arguments);
};

The TC39 Process

ECMA Stages

https://tc39.es/process-document/

Stage 1: proposal

Stage 2: draft

Stage 3: candidate

Stage 4: finished

https://2ality.com/2015/11/tc39-process.html

JavaScript Design Patterns

Decorator

装饰器是一个将功能动态添加到另一个对象的对象。

https://robdodson.me/javascript-design-patterns-decorator/

refs

https://caniuse.com/es5

https://caniuse.com/es6

https://caniuse.com/es6

https://kangax.github.io/compat-table/esnext/

https://www.sitepoint.com/javascript-decorators-what-they-are/

https://www.telerik.com/blogs/decorators-in-javascript

https://www.simplethread.com/understanding-js-decorators/

https://medium.com/jspoint/a-minimal-guide-to-ecmascript-decorators-55b70338215e

https://medium.com/@trekinbami/using-decorators-in-javascript-a44296e418c7

https://dev.to/dpksh/learn-javascript-class-decorators-in-5-minutes-4em7

https://dev.to/angular/decorators-do-not-work-as-you-might-expect-3gmj

https://www.geeksforgeeks.org/what-are-decorators-and-how-are-they-used-in-javascript/

https://stackoverflow.com/questions/34461548/how-can-i-use-decorators-today

https://jsmanifest.com/decorators-in-javascript/



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


ES-Next @Decorator All In One的更多相关文章

  1. 设计模式-装饰者模式(Decorator Pattern)

    本文由@呆代待殆原创,转载请注明出处. 此设计模式遵循的设计原则之一:类应该支持扩展,而拒绝修改(Open-Closed Principle) 装饰者模式简述 装饰者模式通过组合的方式扩展对象的特性, ...

  2. ES 6 装饰器与 React 高阶组件

    关于 Decorator 到底是 ES 6 引入的还是 ES 7 引入的我也不是很明白了,两种说法都有,这种问题懒得纠结了--在用的时候发现这个东西很好用,平常用处可能不大,但是结合 React 就很 ...

  3. Node.js 全栈开发(二)——ES 201x 新语法的使用之基础篇

    在讲 ES 2015 新语法之前,先来说一下为什么叫 ES.JavaScript 是这门语言的名称,它有一个为它制定标准化的组织 European Computer Manufacturers Ass ...

  4. Decorator:从原理到实践

    前言 原文链接:Nealyang/personalBlog ES6 已经不必在过多介绍,在 ES6 之前,装饰器可能并没有那么重要,因为你只需要加一层 wrapper 就好了,但是现在,由于语法糖 c ...

  5. 【AR实验室】OpenGL ES绘制相机(OpenGL ES 1.0版本)

    0x00 - 前言 之前做一些移动端的AR应用以及目前看到的一些AR应用,基本上都是这样一个套路:手机背景显示现实场景,然后在该背景上进行图形学绘制.至于图形学绘制时,相机外参的解算使用的是V-SLA ...

  6. OpenGL ES 3.0: 图元重启(Primitive restart)

    [TOC] 背景概述 在OpenGL绘制图形时,可能需要绘制多个并不相连的图形.这样的情况下这几个图形没法被当做一个图形来处理.也就需要多次调用 DrawArrays 或 DrawElements. ...

  7. 分享一个CQRS/ES架构中基于写文件的EventStore的设计思路

    最近打算用C#实现一个基于文件的EventStore. 什么是EventStore 关于什么是EventStore,如果还不清楚的朋友可以去了解下CQRS/Event Sourcing这种架构,我博客 ...

  8. ES 学习总结

    ES 总结: es 是基于lucene的, 是java 实现的, 很多概念和lucene是相同的 索引-- 对应数据库的表,mongoDB中的集合 文档,由字段组成, 一个字段可以出现多次. 字段,其 ...

  9. ES性能测试

    测试背景   因为ES(ElasticSearch)前段时间查询效率有点慢,技术小组对索引做了一些改动,因此需要测试一下修改后的查询效率,跟之前的结果做一下对比,所以有了这次测试.   需求简述   ...

随机推荐

  1. Jmeter5.1.1 把默认语言调整为中文

    进入安装目录:apache-jmeter-5.1.1\bin\ 找到 jmeter.properties文件 搜索" language=en ",前面带有"#" ...

  2. pull push 监控指标

    Prometheus 原理介绍 - 知乎 https://zhuanlan.zhihu.com/p/70090800 Prometheus由Go语言编写而成,采用Pull方式获取监控信息,并提供了多维 ...

  3. 游戏寻路A*算法

    A*算法是一种启发式的BFS,目的就是找到到达目标位置的最短路径.启发式函数如下: f(x) = g(x) + h(x) g(x)是对出发点到达当前点距离的估约,h(x)是当前点到终点距离的估约.算法 ...

  4. js控制页面元素值

    // TODO id 定位 var ele1 = document.getElementById("test1"); // alert(ele1.value) // TODO 根据 ...

  5. 【算法】数位 dp

    时隔多日,我终于再次开始写博客了!! 上午听了数位 dp,感觉没听懂,于是在网上进行一番愉 ♂ 快 ♀ 的学习后,写篇博来加深一下印象~~ 前置的没用的知识 数位 不同计数单位,按照一定顺序排列,它们 ...

  6. Python骚操作从列表推导和生成器表达式开始

    序列 序列是指一组数据,按存放类型分为容器序列与扁平序列,按能否被修改分为不可变序列与可变序列. 容器序列与扁平序列 容器序列存放的是对象的引用,包括list.tuple.collections.de ...

  7. Jenkins入门教程

    Jenkins入门教程 @ 目录 Jenkins入门教程 1. 什么是Jenkins 1.1 我们为啥需要jenkins 1.2. Jenkin实现原理 2. Jenkins搭建 2.1. Jenki ...

  8. Java——继承,重载,重写三剑客

    About-继承 所有Java的类均是由java.lang.Object类继承而来的,所以Object是所有类的祖先类,而除了Object外,所有类必须有一个父类. 继承可以理解为一个对象从另一个对象 ...

  9. void(*p)()和void*p()区别

    void (*p)()是一个指向函数的指针,表示是一个指向函数入口的指地变量,该函数的返回类型是void类型.它的用法可参看下例: 例如:有一返加void值的函数swap,(swap用来交换两个数) ...

  10. 浅谈Webpack模块打包工具一

    为什么要使用模块打包工具 1.模块化开发ES Modules存在兼容性问题 打包之后成产阶段编译为ES5 解决兼容性问题 2.模块文件过多 网络请求频繁  开发阶段把散的模块打包成一个模块 解决网络请 ...