chore: tidy

This commit is contained in:
cha0s 2020-06-21 22:44:26 -05:00
parent 3ae24411e1
commit 9bc3c2ad12

View File

@ -14,8 +14,8 @@ export class Trait extends decorate(class {}) {
const ctor = this.constructor;
this._fastDirtyCheck = true;
this._memoizedListeners = undefined;
this.params = Object.assign({}, ctor.defaultParams(), params);
this.state = Object.assign({}, ctor.defaultState(), state);
this.params = ctor.defaultParamsWith(params);
this.state = ctor.defaultStateWith(state);
this.previousState = JSON.parse(JSON.stringify(this.state));
if (this.tick) {
this.tick = this.tick.bind(this);
@ -53,10 +53,18 @@ export class Trait extends decorate(class {}) {
return {};
}
static defaultParamsWith(defaults) {
return {...this.defaultParams(), ...defaults};
}
static defaultState() {
return {};
}
static defaultStateWith(defaults) {
return {...this.defaultState(), ...defaults};
}
static dependencies() {
return [];
}