Creating helper methods for the setTimeout uses

Abstracting out some of the setTimeout patterns that have popped up in
the code to make the intention clearer.
This commit is contained in:
Jeff Avallone
2015-03-14 17:27:59 -04:00
parent 0093db8e20
commit 06e66c0f24
5 changed files with 37 additions and 36 deletions
+3 -9
View File
@@ -97,11 +97,7 @@ export default class Regexper {
this.state = '';
if (expression !== '') {
this.renderRegexp(expression).catch(message => {
setTimeout(() => {
throw message;
});
});
this.renderRegexp(expression).catch(util.exposeError);
}
}
@@ -147,10 +143,8 @@ export default class Regexper {
if (this.running) {
this.running.cancel();
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(this.renderRegexp(expression));
}, 10);
util.wait(10).then(() => {
return this.renderRegexp(expression);
});
}