Skip to content

Commit

Permalink
clearTimeout only after all submodules are done
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipStamenkovic committed Nov 2, 2020
1 parent eb55e67 commit 4708487
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,13 @@ function hasGDPRConsent(consentData) {
* @param {function} cb - callback for after processing is done.
*/
function processSubmoduleCallbacks(submodules, cb) {
const done = cb ? utils.delayExecution(cb, submodules.length) : function () { };
let done = () => {};
if (cb) {
done = utils.delayExecution(() => {
clearTimeout(timeoutID);
cb();
}, submodules.length);
}
submodules.forEach(function (submodule) {
submodule.callback(function callbackCompleted(idObj) {
// if valid, id data should be saved to cookie/html storage
Expand All @@ -338,7 +344,6 @@ function processSubmoduleCallbacks(submodules, cb) {
// clear callback, this prop is used to test if all submodule callbacks are complete below
submodule.callback = undefined;
});
clearTimeout(timeoutID);
}

/**
Expand Down

0 comments on commit 4708487

Please sign in to comment.