feat: more intelligent trait state merging

This commit is contained in:
cha0s 2019-03-18 20:03:30 -05:00
parent a014a59e20
commit c1e7db9ebf

View File

@ -11,7 +11,17 @@ export class Trait {
} }
acceptStateChange(change) { acceptStateChange(change) {
this.state = this.state.merge(change); const undefinedProperties = {};
for (const key in change) {
const value = change[key];
if (key in this.entity) {
this.entity[key] = value;
}
else {
undefinedProperties[key] = value;
}
}
this.state = this.state.merge(undefinedProperties);
} }
actions() { actions() {