Slide 41
Slide 41 text
prototype記法のclass構文移行
var SampleComponent = function(items) {
SampleComponent.base(this, 'constructor');
this.items_ = items;
};
goog.inherits(SampleComponent, Component);
SampleComponent.prototype.getItems = function () {
return this.items_;
};
SampleComponent.prototype.disposeInternal =
function () {
SampleComponent.base(this, 'disposeInternal');
};
class SampleComponent extends Component {
constructor(items) {
super();
this.items_ = items;
}
getItems() {
return this.items_;
}
disposeInternal() {
super.disposeInternal();
}
}
closure library独自の継承方法
メソッドの定義が冗長
基底クラスのメソッドを呼ぶのも長い
ES2015準拠の継承方法
メソッドの定義も
呼び出しも完結
読むのもつらいし書くのも楽しくない