Skip to content

Commit

Permalink
fix: fix dispatch callback bug
Browse files Browse the repository at this point in the history
  • Loading branch information
imtaotao committed Dec 21, 2019
1 parent 6cdb303 commit a92587e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 36 deletions.
16 changes: 9 additions & 7 deletions demo/store/mpstore.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Mpstore.js v0.1.12
* Mpstore.js v0.1.13
* (c) 2019-2019 Imtaotao
* Released under the MIT License.
*/
Expand Down Expand Up @@ -532,16 +532,18 @@ function updateComponents(store, callback) {
var hooks = store.hooks,
GLOBALWORD = store.GLOBALWORD,
depComponents = store.depComponents;
var len = depComponents.length;

if (len === 0) {
if (depComponents.length === 0) {
callback();
return;
}

var renderedCallback = function renderedCallback() {
if (++total === len) {
callback();
if (++total === depComponents.length) {
if (!callback._called) {
callback._called = true;
callback();
}
}
};

Expand Down Expand Up @@ -847,7 +849,7 @@ function () {
this.depComponents = [];
this.GLOBALWORD = 'global';
this.isDispatching = false;
this.version = '0.1.12';
this.version = '0.1.13';
this.state = Object.freeze(createModule({}));
this.middleware = new Middleware(this);
}
Expand Down Expand Up @@ -1111,7 +1113,7 @@ function () {
return Store;
}();

var version = '0.1.12';
var version = '0.1.13';
var nativePage = Page;
var nativeComponent = Component;

Expand Down
16 changes: 9 additions & 7 deletions dist/mpstore.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Mpstore.js v0.1.12
* Mpstore.js v0.1.13
* (c) 2019-2019 Imtaotao
* Released under the MIT License.
*/
Expand Down Expand Up @@ -536,16 +536,18 @@ function updateComponents(store, callback) {
var hooks = store.hooks,
GLOBALWORD = store.GLOBALWORD,
depComponents = store.depComponents;
var len = depComponents.length;

if (len === 0) {
if (depComponents.length === 0) {
callback();
return;
}

var renderedCallback = function renderedCallback() {
if (++total === len) {
callback();
if (++total === depComponents.length) {
if (!callback._called) {
callback._called = true;
callback();
}
}
};

Expand Down Expand Up @@ -851,7 +853,7 @@ function () {
this.depComponents = [];
this.GLOBALWORD = 'global';
this.isDispatching = false;
this.version = '0.1.12';
this.version = '0.1.13';
this.state = Object.freeze(createModule({}));
this.middleware = new Middleware(this);
}
Expand Down Expand Up @@ -1115,7 +1117,7 @@ function () {
return Store;
}();

var version = '0.1.12';
var version = '0.1.13';
var nativePage = Page;
var nativeComponent = Component;

Expand Down
16 changes: 9 additions & 7 deletions dist/mpstore.es6m.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Mpstore.js v0.1.12
* Mpstore.js v0.1.13
* (c) 2019-2019 Imtaotao
* Released under the MIT License.
*/
Expand Down Expand Up @@ -395,14 +395,16 @@ function updateComponents (store, callback) {
GLOBALWORD,
depComponents,
} = store;
const len = depComponents.length;
if (len === 0) {
if (depComponents.length === 0) {
callback();
return
}
const renderedCallback = () => {
if (++total === len) {
callback();
if (++total === depComponents.length) {
if (!callback._called) {
callback._called = true;
callback();
}
}
};
for (let i = 0; i < depComponents.length; i++) {
Expand Down Expand Up @@ -667,7 +669,7 @@ class Store {
this.depComponents = [];
this.GLOBALWORD = 'global';
this.isDispatching = false;
this.version = '0.1.12';
this.version = '0.1.13';
this.state = Object.freeze(createModule({}));
this.middleware = new Middleware(this);
}
Expand Down Expand Up @@ -908,7 +910,7 @@ class Store {
}
}

const version = '0.1.12';
const version = '0.1.13';
const nativePage = Page;
const nativeComponent = Component;
function expandConfig (config, expandMethods, isPage) {
Expand Down
16 changes: 9 additions & 7 deletions dist/mpstore.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Mpstore.js v0.1.12
* Mpstore.js v0.1.13
* (c) 2019-2019 Imtaotao
* Released under the MIT License.
*/
Expand Down Expand Up @@ -532,16 +532,18 @@ function updateComponents(store, callback) {
var hooks = store.hooks,
GLOBALWORD = store.GLOBALWORD,
depComponents = store.depComponents;
var len = depComponents.length;

if (len === 0) {
if (depComponents.length === 0) {
callback();
return;
}

var renderedCallback = function renderedCallback() {
if (++total === len) {
callback();
if (++total === depComponents.length) {
if (!callback._called) {
callback._called = true;
callback();
}
}
};

Expand Down Expand Up @@ -847,7 +849,7 @@ function () {
this.depComponents = [];
this.GLOBALWORD = 'global';
this.isDispatching = false;
this.version = '0.1.12';
this.version = '0.1.13';
this.state = Object.freeze(createModule({}));
this.middleware = new Middleware(this);
}
Expand Down Expand Up @@ -1111,7 +1113,7 @@ function () {
return Store;
}();

var version = '0.1.12';
var version = '0.1.13';
var nativePage = Page;
var nativeComponent = Component;

Expand Down
Loading

0 comments on commit a92587e

Please sign in to comment.