Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sync run to be scheduled. #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Scheduler.js
Expand Up @@ -72,10 +72,19 @@ class Queue extends Emitter {

this.workingTask_ = task;

task.run().then(() => {
const completeWork = () => {
this.workingTask_ = null;
this.dequeue();
});
};

// The return value of a task run should not be
// async by definition, it might aswell be sync, or undefined.
const value = task.run();
if (value instanceof Promise) {
value.then(completeWork);
} else {
completeWork();
}
}

flush() {
Expand Down