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
@@ -57,15 +57,13 @@ export default class Node {
|
||||
return this.container.transform(matrix);
|
||||
}
|
||||
|
||||
deferredStep() {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
if (this.state.cancelRender) {
|
||||
reject('Render cancelled');
|
||||
} else {
|
||||
resolve.apply(this, arguments);
|
||||
}
|
||||
}, 1);
|
||||
deferredStep(value) {
|
||||
return util.tick().then(() => {
|
||||
if (this.state.cancelRender) {
|
||||
throw 'Render cancelled';
|
||||
}
|
||||
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user