Jump to navigation

Namespace: schedule

Numbas.schedule

Schedule functions to be called. The scheduler can put tiny timeouts in between function calls so the browser doesn't become unresponsive. It also updates the loading bar.

Source:

Members

(static) calls :Array.<function()>

Functions to call.

Type:
Source:

(static) completed :number

Number of tasks completed.

Type:
Source:

(static) halt_error :Error

Error which caused the scheduler to halt.

Type:
Source:

(static) halted :boolean

Should the scheduler stop running tasks? Don't use this directly - use Numbas.schedule.halt.

Type:
Source:

(static) lifts :Array.<Array.<function()>>

Bits of queue that have been picked up while a task performs sub-tasks.

Type:
Source:

(static) signalboxes :Array.<Numbas.schedule.SignalBox>

All signal box objects.

Type:
Source:

(static) total :number

Total number of tasks ever scheduled.

Type:
Source:

Methods

(static) add(fn, that)

Add a task to the queue.

Parameters:
Name Type Description
fn function | Numbas.schedule.task_object

The function to run, or a dictionary {task: fn, error: fn}, where error is a callback if an error is caused.

that object

What this should be when the function is called.

Source:

(static) drop()

Put the last lifted queue back on the end of the real queue.

Source:

(static) halt(error)

Prevent the scheduler from running any more tasks, and save the error message which caused this.

Parameters:
Name Type Description
error Error
Source:
See:

(static) lift()

Pick up the current queue and put stuff in front. Called before running a task, so it can queue things which must be done before the rest of the queue is called.

Source:

(static) pop()

Pop the first task off the queue and run it.

If there's an error, the scheduler halts and shows the error.

Source:

(static) reset()

Reset the scheduler: remove all callbacks and signal boxes.

Source:

(static) unhalt()

Allow the scheduler to run tasks again. Unhalts all signalboxes too.

Source:

Type Definitions

callback

Type:
Properties:
Name Type Description
Promise Promise
resolve function

The promise's resolve function.

reject function

The promise's reject function.

resolved boolean

Has the promise been resolved?

Source:

task_object

Type:
Properties:
Name Type Description
task function

The function to execute.

error function

A callback, used if an error is raised.

Source: