Skip to content

Commit

Permalink
List all jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
nwehrhan committed Dec 2, 2024
1 parent ec43d02 commit dfec054
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/job-scheduler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export interface JobScheduler {
* Schedule a job. If a job with the same `id` has already been scheduled, it will update the job if it is different.
*/
scheduleJob(job: Job): Promise<void>;

/**
* Un-schedules a job by it's ID.
*/
Expand All @@ -95,10 +96,16 @@ export interface JobScheduler {
* Listen for a job to finish successfully.
*/
on(event: 'success', callback: (job: Job, result: any) => void): RemoveListenerFn;

/**
* Listen for when a job fails.
*/
on(event: 'error', callback: (job: Job, error: unknown) => void): RemoveListenerFn;

/**
* List all the scheduled jobs.
*/
listJobs(): Promise<Alarms.Alarm>;
}

/**
Expand Down Expand Up @@ -227,6 +234,11 @@ export function defineJobScheduler(options?: JobSchedulerConfig): JobScheduler {
}
}

async function listJobs() {
logger?.debug('Listing jobs: ');
return await browser.alarms.getAll();
}

/**
* Some jobs need to immediately schedule the next alarm, some don't. This function handles each
* type and calls `scheduleJob` if needed.
Expand Down

0 comments on commit dfec054

Please sign in to comment.