refactor: simplify flow
This commit is contained in:
parent
b591e5b08f
commit
f6a461d2d5
|
@ -70,16 +70,10 @@ export class Actions extends decorate(Traversals) {
|
||||||
}
|
}
|
||||||
|
|
||||||
parallel(context) {
|
parallel(context) {
|
||||||
let immediate = true;
|
|
||||||
const results = this.traversals.map((traversal) => {
|
const results = this.traversals.map((traversal) => {
|
||||||
const result = traversal.traverse(context);
|
return traversal.traverse(context);
|
||||||
// Side-effect for performance.
|
|
||||||
if (result instanceof Promise) {
|
|
||||||
immediate = false;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
});
|
});
|
||||||
return immediate ? results : TickingPromise.all(results);
|
return TickingPromise.all(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
prologue() {
|
prologue() {
|
||||||
|
@ -90,12 +84,7 @@ export class Actions extends decorate(Traversals) {
|
||||||
}
|
}
|
||||||
|
|
||||||
serial(context) {
|
serial(context) {
|
||||||
// Immediate tick. Maybe we can avoid a promise?
|
return this.tickingPromise(context);
|
||||||
this.tick(context, 0);
|
|
||||||
// If it's pending, we have to return a ticking promise.
|
|
||||||
if (this.pending) {
|
|
||||||
return this.tickingPromise(context);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tickingPromise(context) {
|
tickingPromise(context) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user