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

+7 -9
View File
@@ -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;
});
}