Skip to content

Commit 6109ba8

Browse files
authored
Merge pull request PAIR-code#20 from cBioCenter/add-timeouts-forlong-methods
Added timeouts to optimizeLayoutAsync
2 parents 90fdf28 + d7c7b5a commit 6109ba8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/umap-js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ var UMAP = (function () {
16161616
shouldStop = epochCallback(epochCompleted) === false;
16171617
isFinished = epochCompleted === nEpochs;
16181618
if (!shouldStop && !isFinished) {
1619-
step();
1619+
setTimeout(function () { return step(); }, 0);
16201620
}
16211621
else {
16221622
return [2, resolve(isFinished)];
@@ -1628,7 +1628,7 @@ var UMAP = (function () {
16281628
return [2];
16291629
});
16301630
}); };
1631-
step();
1631+
setTimeout(function () { return step(); }, 0);
16321632
});
16331633
};
16341634
UMAP.prototype.optimizeLayout = function (epochCallback) {

lib/umap-js.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/umap.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export interface UMAPParameters {
8383
* The distance function with which to assess nearest neighbors, defaults
8484
* to euclidean distance.
8585
*/
86-
distanceFn?: DistanceFn
86+
distanceFn?: DistanceFn;
8787
/**
8888
* The initial learning rate for the embedding optimization.
8989
*/
@@ -1023,15 +1023,15 @@ export class UMAP {
10231023
const shouldStop = epochCallback(epochCompleted) === false;
10241024
const isFinished = epochCompleted === nEpochs;
10251025
if (!shouldStop && !isFinished) {
1026-
step();
1026+
setTimeout(() => step(), 0);
10271027
} else {
10281028
return resolve(isFinished);
10291029
}
10301030
} catch (err) {
10311031
reject(err);
10321032
}
10331033
};
1034-
step();
1034+
setTimeout(() => step(), 0);
10351035
});
10361036
}
10371037

0 commit comments

Comments
 (0)