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:
1 parent
0093db8e20
commit
06e66c0f24
5 files changed
+37
-36
No files matched your search
+20
-1
@@ -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
|
||||
};
|
||||
Reference in new issue
Block a user