API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classCoroutine
@codexo/exojs / core / stable
Handle for work handed to a CoroutineSystem. Poll Coroutine.status, Coroutine.progress and Coroutine.result from frame code, or await Coroutine.done from async code; both see the same settlement. Cancelling (or destroying, which is the same) stops the body at its current `yield` and settles the coroutine as `cancelled`.
8
props
2
methods
0
events
Import
import { Coroutine } from '@codexo/exojs'Handle for work handed to a CoroutineSystem. Poll Coroutine.status, Coroutine.progress and Coroutine.result from frame code, or await Coroutine.done from async code; both see the same settlement. Cancelling (or destroying, which is the same) stops the body at its current `yield` and settles the coroutine as `cancelled`.
Methods2
cancel(): voidStop the coroutine at its current yield. No-op once settled.
destroy(): voidProperties8
name: string | undefinedThe label passed at CoroutineSystem.queue, if any.
done: Promise<T>Resolves with the result when the coroutine completes and rejects when it fails or is cancelled (cancellation rejects with an AbortError). Created on first access, so a coroutine nobody awaits never raises an unhandled rejection. The continuation runs after the frame step that settled it; read Coroutine.result for same-frame access.
error: Error | undefinedThe error that failed or cancelled the coroutine, otherwise undefined. A thrown non-Error value is wrapped, with the value as cause.
priority: numberFirst claim on the frame's slice. Writable while the coroutine runs, so work the player is now waiting on can be promoted ahead of the rest; the system reorders before its next frame.
progress: P | undefinedThe most recent value the body yielded, or undefined before the first step. A body that yields nothing types this as void.
result: T | undefinedThe body's return value once the coroutine is done, otherwise undefined.
settled: booleanWhether the coroutine has reached a terminal state.
Source