From 8e82a8612a95357b4e63f4487ce69a7d571e6971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Thu, 21 Mar 2019 09:11:44 +0100 Subject: [PATCH] small cleanup of the store --- src/store.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/store.ts b/src/store.ts index 6e76b55f..2554b080 100644 --- a/src/store.ts +++ b/src/store.ts @@ -43,18 +43,18 @@ export class Store extends EventBus { ); } - commit(type, payload) { + async commit(type, payload) { if (!this.mutations[type]) { throw new Error(`[Error] mutation ${type} is undefined`); } this._isMutating = true; + this.mutations[type].call(null, this._state, payload); - Promise.resolve().then(() => { - if (this._isMutating) { - this._isMutating = false; - this.trigger("update"); - } - }); + await Promise.resolve(); + if (this._isMutating) { + this._isMutating = false; + this.trigger("update"); + } } _clone(obj) {