Internationalisation
Bundled Plugins API
CooperativeScheduler
Manages Observables using coroutines and a virtual clock that must be updated manually.

API Overview

  • Constructors - API calls which return an object, typically one that offers API methods
  • create
  • Methods - API calls which can only be made on an object returned by a constructor
  • isEmpth
  • schedule
  • update

API Documentation

Constructors

create

Signature
cp.rx.CooperativeScheduler.create([currentTime]) -> cp.rx.CooperativeScheduler
Type
Constructor
Description
Creates a new CooperativeScheduler.
Parameters
  • currentTime - A time to start the scheduler at. Defaults to 0.
Returns
  • The new CooperativeScheduler.

Methods

isEmpth

Signature
cp.rx.CooperativeScheduler:isEmpth() -> cp.rx.CooperativeScheduler
Type
Method
Description
Returns whether or not the CooperativeScheduler's queue is empty.
Returns
  • true if the scheduler is empty, otherwise false.

schedule

Signature
cp.rx.CooperativeScheduler:schedule(action[, delay]) -> cp.rx.Reference
Type
Method
Description
Schedules a function to be run after an optional delay. Returns a Reference that will stop
Parameters
  • action - The function to execute. Will be converted into a coroutine. The coroutine may yield execution back to the scheduler with an optional number, which will put it to sleep for a time period.
  • delay - Delay execution of the action by a virtual time period. Defaults to 0.
Returns

update

Signature
cp.rx.CooperativeScheduler:update(delta) -> nil
Type
Method
Description
Triggers an update of the CooperativeScheduler. The clock will be advanced and the scheduler
Parameters
  • delta - An amount of time to advance the clock by. It is common to pass in the
Last modified 1mo ago