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:
  • Scheduler.Event.FLIP_REPEAT:
  • Scheduler.Event.FLIP_NEXT:
  • Scheduler.Event.QUIT:

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 PsychoJS the PsychoJS instance
Source:

Members

add

Schedule a new task.
Source:

addConditional

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

Note: the tasks are sub-schedulers.

Source:

(readonly) Event :Symbol

Events.
Type:
  • Symbol
Source:

run

Run the next scheduled tasks in sequence until one of them returns something other than Scheduler.Event.NEXT.
Source:

start

Start this scheduler.

Note: tasks are run after each animation frame.

Source:

stop

Stop this scheduler at the next update.
Source:

Type Definitions

Condition() → {boolean}

Condition evaluated when the task is run.
Source:
Returns:
Type
boolean

Task(argsopt)

Task to be run by the scheduler.
Parameters:
Name Type Attributes Description
args * <optional>
optional arguments
Source: