refactor: improve setState semantics
This commit is contained in:
@@ -59,15 +59,13 @@ export class PureViewCtrl<P = CtrlProps, S = CtrlState> {
|
|||||||
return {} as any;
|
return {} as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setState(state: CtrlState) {
|
async setState(state: Partial<S>) {
|
||||||
if (!this.$timeout) {
|
if (!this.$timeout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.state = Object.freeze(Object.assign({}, this.state, state));
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
this.stateTimeout = this.$timeout(() => {
|
this.stateTimeout = this.$timeout(resolve);
|
||||||
this.state = Object.freeze(Object.assign({}, this.state, state));
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user