# JSDoc: Class: Scheduler

# Class: Scheduler

## util.Scheduler(psychoJS)

#### new Scheduler(psychoJS)

A scheduler helps run the main loop by managing scheduled functions, called tasks, after each frame is displayed.

Tasks are either another Scheduler, or a JavaScript functions returning one of the following codes:

- Scheduler.Event.NEXT: Move onto the next task *without* rendering the scene first.
- Scheduler.Event.FLIP_REPEAT: Render the scene and repeat the task.
- Scheduler.Event.FLIP_NEXT: Render the scene and move onto the next task.
- Scheduler.Event.QUIT: Quit the scheduler.

It is possible to create sub-schedulers, e.g. to handle loops. Sub-schedulers are added to a parent scheduler as a normal task would be by calling scheduler.add(subScheduler).

Conditional branching is also available: scheduler.addConditionalBranches

##### Parameters:

Name | Type | Description
--- | --- | ---
`psychoJS` | module:core.PsychoJS | the PsychoJS instance

Source:
  - util/Scheduler.js, line 10

### Members

#### add

Schedule a new task.

Source:
  - util/Scheduler.js, line 73

#### addConditional

Schedule a series of task or another, based on a condition.

Note: the tasks are sub-schedulers.

Source:
  - util/Scheduler.js, line 93

#### (readonly) Event :Symbol

Events.

##### Type:

- Symbol

Source:
  - util/Scheduler.js, line 260

#### start

Start this scheduler.

Note: tasks are run after each animation frame.

Source:
  - util/Scheduler.js, line 124

#### status

Get the status of the scheduler.

Source:
  - util/Scheduler.js, line 55

#### (readonly) Status :Symbol

Status.

##### Type:

- Symbol

Source:
  - util/Scheduler.js, line 290

#### stop

Stop this scheduler.

Source:
  - util/Scheduler.js, line 171

### Type Definitions

#### Condition() → {boolean}

Condition evaluated when the task is run.

Source:
  - util/Scheduler.js, line 87

##### Returns:

Type
  boolean

#### Task(argsopt)

Task to be run by the scheduler.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`args` | * | <optional> | optional arguments

Source:
  - util/Scheduler.js, line 67