# cp.rx.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.
Notes None
Examples None
Source src/extensions/cp/rx/CooperativeScheduler.lua line 18

# Methods

# isEmpth

Signature cp.rx.CooperativeScheduler:isEmpth() -> cp.rx.CooperativeScheduler
Type Method
Description Returns whether or not the CooperativeScheduler's queue is empty.
Parameters
  • None
Returns
  • true if the scheduler is empty, otherwise false.
Notes None
Examples None
Source src/extensions/cp/rx/CooperativeScheduler.lua line 102

# 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 the action from running.
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
Notes None
Examples None
Source src/extensions/cp/rx/CooperativeScheduler.lua line 36

# 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 will run any coroutines that are due to be run.
Parameters
  • delta - An amount of time to advance the clock by. It is common to pass in the time in seconds or milliseconds elapsed since this function was last called. Defaults to 0.
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/rx/CooperativeScheduler.lua line 67