ref: move PureWidget back to core, use updateEnv

This commit is contained in:
Géry Debongnie
2019-03-21 16:33:08 +01:00
parent ad9fb77458
commit add380f59b
4 changed files with 31 additions and 35 deletions
+18
View File
@@ -407,3 +407,21 @@ export class Component<
}
}
}
export class PureComponent<E extends Env, P, S> extends Component<E, P, S> {
shouldUpdate(nextProps: P): boolean {
for (let k in nextProps) {
if (nextProps[k] !== this.props[k]) {
return true;
}
}
return false;
}
async updateState(nextState: Partial<S>) {
for (let k in nextState) {
if (nextState[k] !== this.state[k]) {
return super.updateState(nextState);
}
}
}
}
+9 -2
View File
@@ -1,6 +1,13 @@
import { QWeb } from "./qweb";
import { EventBus } from "./event_bus";
import { Component } from "./component";
import { Component, PureComponent } from "./component";
import { Store, StoreMixin } from "./store";
export const core = { QWeb, EventBus, Component, Store, StoreMixin };
export const core = {
QWeb,
EventBus,
Component,
PureComponent,
Store,
StoreMixin
};