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. jvm源码解析java对象头

    认真学习过java的同学应该都知道,java对象由三个部分组成:对象头,实例数据,对齐填充,这三大部分扛起了java的大旗对象,实例数据其实就是我们对象中的数据,对齐填充是由于为了规则分配内存空间,j ...

  2. JavaScript中原型对象的应用!

    JavaScript中原型对象的应用! 扩展内置对象的方法 我以数组对象为例! // 原型对象的应用 扩展内置对象方法! Array.prototype.sum = function() { var ...

  3. 【python刷题】LRU

    什么是LRU? LRU是Least Recently Used的缩写,即最近最少使用,是一种常用的页面置换算法,选择最近最久未使用的页面予以淘汰.该算法赋予每个页面一个访问字段,用来记录一个页面自上次 ...

  4. HTML Standard系列:Event loop、requestIdleCallback 和 requestAnimationFrame

    HTML Standard系列:Event loop.requestIdleCallback 和 requestAnimationFrame - 掘金 https://juejin.im/post/5 ...

  5. cpp异常机制思考

    https://www.cnblogs.com/qq329914874/p/6734701.html

  6. pycharm创建文件夹以及查看源文件存放位置(FOR MAC)

    1.首先我们打开pycharm软件,一般首次打开界面如下 2.我们点击creat new project,点击后效果如下,此时创建相应的文件夹 3.创建完成后如下,并可以查看存放文件夹的位置 4.完成 ...

  7. STM32 定时器详细篇(基于HAL库)

    l  16位的向上.向下.向上/向下(中心对齐)计数模式,支持自动重装载 l  16位的预分频器 l  每个定时器都有多个独立通道,每个通道可用于 *  输入捕获 *  输出比较 *  PWM输出 * ...

  8. IDEA中jdk设置

    电脑运行环境是8, 但是IDEA提醒说1.5已经过时,IDEA中jdk设置还是比较麻烦 https://blog.csdn.net/u012365843/article/details/8138883 ...

  9. Prometheus为你的SpringBoot应用保驾护航

    前面我们介绍了Prometheus的作用和整体的架构,相信大家对Prometheus有了一定的了解. 具体可以查看这篇文章:https://mp.weixin.qq.com/s/QoAs0-AYy8k ...

  10. wmi_exporter+Prometheus+Grafana

    wmi_exporter+Prometheus+Grafana 原文地址: CSDN:NRlovestudy:Windows 下搭建 wmi_exporter+Prometheus+Grafana 服 ...