web:fix cannot execute hookAfter in web promise,use setTimeout instead

This commit is contained in:
pengfei.zhou
2021-04-13 18:28:45 +08:00
committed by osborn
parent ace3d30e73
commit 4873ff535d
18 changed files with 140 additions and 1640 deletions

View File

@@ -52,9 +52,11 @@ class CounterView extends ViewHolder {
class CounterVM extends ViewModel<CountModel, CounterView> {
onAttached(s: CountModel, vh: CounterView) {
vh.counter.onClick = () => {
this.updateState((state) => {
state.count++;
});
Promise.resolve(this.getState().count).then(count => {
this.updateState((state) => {
state.count = count + 1;
});
})
};
}
onBind(s: CountModel, vh: CounterView) {