Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
50 lines (40 loc) · 3.98 KB

cp.rx.CooperativeScheduler.md

File metadata and controls

50 lines (40 loc) · 3.98 KB

docs » 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

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

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.
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
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