#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

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Constructors

Signaturecp.rx.CooperativeScheduler.create([currentTime]) -> cp.rx.CooperativeScheduler
TypeConstructor
DescriptionCreates a new CooperativeScheduler.
Parameters
  • currentTime - A time to start the scheduler at. Defaults to 0.
Returns
  • The new CooperativeScheduler.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/CooperativeScheduler.lua line 18

#Methods

Signaturecp.rx.CooperativeScheduler:isEmpth() -> cp.rx.CooperativeScheduler
TypeMethod
DescriptionReturns whether or not the CooperativeScheduler's queue is empty.
Parameters
  • None
Returns
  • true if the scheduler is empty, otherwise false.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/CooperativeScheduler.lua line 102

Signaturecp.rx.CooperativeScheduler:schedule(action[, delay]) -> cp.rx.Reference
TypeMethod
DescriptionSchedules 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
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/CooperativeScheduler.lua line 36

Signaturecp.rx.CooperativeScheduler:update(delta) -> nil
TypeMethod
DescriptionTriggers 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
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/CooperativeScheduler.lua line 67