Closed
Description
Following the mixin sample from here, I propose a new keyword for implementing mixins. The goal is to keep the code as clean as possible by letting the compiler know that applyMixins has to be included in the codebase and it must be called. Let's say the keyword is 'mixin', the aforementioned example would then be brought down to
class SmartObject mixin Disposable, Activatable {
constructor() {
setInterval(() => console.log(this.isActive + " : " + this.isDisposed), 500);
}
interact() {
this.activate();
}
}
An alternative way to declare it in order to avoid confusion with implements/extends:
class SmartObject {
mixin Disposable
mixin Activatable
constructor() {
setInterval(() => console.log(this.isActive + " : " + this.isDisposed), 500);
}
interact() {
this.activate();
}
}
The compiler would then add the applyMixins function and call it as shown in the article.