You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@traits() is deprecated in favor of .with().
The @traits decorator can only run after a class is defined and will overwrite methods defined in the class in place, modifying the Class prototype and won't allow super() calls.
New Syntax:
//---------------------native class-based traits-----------------
class TraitX {
foo(){
alert("foo X")
}
}
class TraitZ {
zee(){
alert("zee")
}
}
//---------------------classes that mix in traits-----------------
class Y {
constructor(){
alert("cctor of Y")
}
bar(){
alert("bar")
}
}
class T extends Y.with(TraitX,TraitZ) {
constructor(){
super();
this.foo()
}
foo(){
alert("foo T");
super.foo();//from TraitX
this.bar()//from Y
this.zee()//from TraitZ
}
}
The text was updated successfully, but these errors were encountered:
The above is valid JavaScript. And will stay supported.
NEW PROPOSAL
As an added enhancement, modify transpiler to interpret the following cleaner syntax:
class T extends Y with TraitX, TraitZ {
constructor(){
super();
this.foo()
}
foo(){
alert("foo T");
super.foo();//from TraitX
this.bar()//from Y
this.zee()//from TraitZ
}
}
@traits() is deprecated in favor of .with().
The @traits decorator can only run after a class is defined and will overwrite methods defined in the class in place, modifying the Class prototype and won't allow super() calls.
New Syntax:
The text was updated successfully, but these errors were encountered: