2020. 10. 2. 14:54, Developer
프로퍼티에 적용
function firstDecorator(target, name){
console.log('firstDecorator');
console.log(target,name);
}
class Person{
@firstDecorator
job:'dancer';
@firstDecorator
age:30;
}
const p=new Person();
=================================
인스턴스 생성전에 decorator 전부 발동됨(미리 준비)
객체 생성문 없어도 준비됨.
인스턴스 생성하면 발동된것을 박는거임
function firstDecorator(param){
console.log('factory');
return function(target,name){
console.log('decorator');
}
}
class SomeClass{
@firstDecorator(123)
prop='a';
}
console.log('인스턴스 생성 전');
console.log(new SomeClass());
'Developer' 카테고리의 다른 글
[typescript]Decorator - property에 decorator 붙혀서 통제하기 (0) | 2020.10.02 |
---|---|
[typescript]Decorator - 메소드에 decorator 붙혀서 통제하기 (0) | 2020.10.02 |
[typescript]Generic type 응용 (0) | 2020.10.02 |
[typescript]Generic type - 2개이상 타입 (0) | 2020.10.02 |
[typescript]Generic type - 상속 (0) | 2020.10.02 |
Comments, Trackbacks