API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

T

typeCoroutineBody

@codexo/exojs / core / stable

Work a CoroutineSystem advances one step per frame: a generator function whose every `yield` hands control back to the frame. Its return value becomes the coroutine's result, and each yielded value its Coroutine.progress. The `budget` argument reports how much of the driver's slice is left, so a body that wants to fill the frame loops on it and one that only wants to sequence over frames ignores it: ```ts // Sequencing: one yield is one frame. function* blink(): Generator<void, void> { for (let i = 0; i < 3; i++) { toggle(); yield; } } // Time-slicing: as many units as fit, reporting progress. const buildWorld = (map: WorldMap) => function* (budget: FrameBudget): Generator<number, World> { let placed = 0; while (placed < map.chunks.length) { do { placeChunk(map.chunks[placed++]!); } while (placed < map.chunks.length && budget.timeRemaining() > 0); yield placed / map.chunks.length; } return map.build(); }; ``` A body that takes arguments is written curried, as `buildWorld` is above, so the call site stays free of wrapper lambdas.

0
props
0
methods
0
events
Import
import { CoroutineBody } from '@codexo/exojs'

Work a CoroutineSystem advances one step per frame: a generator function whose every `yield` hands control back to the frame. Its return value becomes the coroutine's result, and each yielded value its Coroutine.progress.

The `budget` argument reports how much of the driver's slice is left, so a body that wants to fill the frame loops on it and one that only wants to sequence over frames ignores it:

```ts // Sequencing: one yield is one frame. function* blink(): Generator<void, void> { for (let i = 0; i < 3; i++) { toggle(); yield; } }

// Time-slicing: as many units as fit, reporting progress. const buildWorld = (map: WorldMap) => function* (budget: FrameBudget): Generator<number, World> { let placed = 0;

while (placed < map.chunks.length) { do { placeChunk(map.chunks[placed++]!); } while (placed < map.chunks.length && budget.timeRemaining() > 0);

yield placed / map.chunks.length; }

return map.build(); }; ```

A body that takes arguments is written curried, as `buildWorld` is above, so the call site stays free of wrapper lambdas.

Definition1
Source