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 committed 2015-03-14 17:27:59 -04:00
1 parent 0093db8e20
commit 06e66c0f24
5 files changed
+37 -36

No files matched your search

+20 -1
View File
@@ -71,9 +71,28 @@ function spaceVertically(items, options) {
}
}
function wait(delay) {
return new Promise((resolve, reject) => {
setTimeout(resolve, delay);
});
}
function tick() {
return wait(0);
}
function exposeError(error) {
tick().then(() => {
throw error;
});
}
export default {
customEvent,
normalizeBBox,
spaceHorizontally,
spaceVertically
spaceVertically,
wait,
tick,
exposeError
};