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. LOJ10104Blockade

    POI 2008 Byteotia 城市有 n 个城镇,m 条双向道路.每条道路连接两个不同的城镇,没有重复的道路,所有城镇连通.输出 n 个数,代表如果把第i  个点去掉,将有多少对点不能互通. 输 ...

  2. codevs 1344 模拟退火

    1344 线型网络  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamo   题目描述 Description 有 N ( <=20 ) 台 PC 放在机房内 ...

  3. 用RabbitMQ了好几年之后,我总结出来5点RabbitMQ的使用心得

    大概从 2013 年开始,我就开始了自己和 RabbitMQ 的接触,到现在已经有七年多了. 在这七年中,既有一些对 RabbitMQ 的深度体验,更有无数的血泪史. 而根据我这么多年的使用经验,我将 ...

  4. Docker综述

    Docker综述 1.Docker是干什么的? 2.Docker的核心:镜像.容器.仓库 2.1 容器与虚拟机的区别 2.2 仓库 Docker作用 3.Docker的使用 1.Docker是干什么的 ...

  5. Dbeaver 连接 phoenix

    Dbeaver 连接 phoenix 1.新建连接 2.选择连接类型Phoenix 3.设置驱动 4.准备驱动包 5.添加驱动 6.添加 Zookeeper Base Path 7.找到驱动类 8.配 ...

  6. hbase伪分布式环境的搭建

    一,实验环境: 1, ubuntu server 16.04 2, jdk,1.8 3, hadoop 2.7.4 伪分布式环境或者集群模式 4, hbase-1.2.6.tar.gz 二,环境的搭建 ...

  7. OpenStack (glance 镜像服务)

    glance介绍 glance 提供云虚拟机上的服务镜像(Image)功能,该模块可看成车间里的模具生产部门,其功能包括虚拟机镜像的查找.注册和检索等.该模具最基本的使用方式就是在为云虚拟机实例提供安 ...

  8. 1. Centos 7重置root密码

    1.开机启动系统,不断按"↑"和"↓",在如下引导界面按"e",编辑引导项 2.按"↓"找到下图显示的代码 删除代码最后 ...

  9. Scala面向对象—类详解2(继承相关)

    1.单例类 package com.zzzy class AAA {//单例 /*//java 思路--私有化构造方法,提供公开的getAAA 行不通 private def this(){ this ...

  10. DFS——求图的连通性问题

    DFS作为一个竞赛必学的一个知识点,怎么说我都得写一下 遍历就相当于爆搜,只不过是搜的方式比较规整罢了. 深度优先遍历:为了避免重复访问某个顶点,可以设一个标志数组vis[i],未访问时值为0,访问一 ...