RGJS6 Scheduler

A scheduler for running jobs, inspired by the Scheduling API.

Getting started

Install via npm:

npm install rgjs6-scheduler

Usage

See https://unpkg.com/rgjs6-scheduler@latest/jsdoc/index.html

import Scheduler from 'rgjs6-scheduler';

const scheduler = new Scheduler();

scheduler.postTask(() => {
  // Do some work
  // ..
});

scheduler.postTasks([
  () => {
    // Do some more work
    // ..
  },
  () => {
    // And some more
    // ..
  },
]);

scheduler.postTask(() => {
  // Do some background work
  // This will only execute when higher priority work is finished
}, {
  priority: Scheduler.Constants.PRIORITY_LOW,
});

scheduler.postTask(() => {
  // Prioritize this work over normal and low priority work
  // Will not yield the main thread
}, {
  priority: Scheduler.Constants.PRIORITY_HIGH,
})