API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classDestroyScope
Ownership container for Destroyable resources. Items registered with track are destroyed in reverse registration order when the scope itself is destroyed - the spine of ExoJS's ownership-driven cleanup. A Scene owns one for its whole lifetime, exposed as `Scene.track`. An `Application` does not: it creates one for the duration of its constructor, to release the subsystems already built if a later construction step throws (the caller never receives an instance, so `destroy()` is unreachable). Its own `Application.destroy()` runs an explicit ordered teardown instead, because the WebGPU→WebGL2 backend fallback replaces subsystems after construction, which a long-lived scope would not follow. `track` is idempotent and returns its argument for fluent capture: ```ts const world = scope.track(new PhysicsWorld()); ``` destroy is idempotent and tolerant: every tracked item's `destroy()` is attempted even if an earlier one throws, so a single failure cannot leak the rest. In development the collected errors are rethrown as an `AggregateError` once teardown completes; in production they are swallowed. A `DestroyScope` is itself Destroyable, so scopes can nest.
import { DestroyScope } from '@codexo/exojs'Ownership container for Destroyable resources. Items registered with track are destroyed in reverse registration order when the scope itself is destroyed - the spine of ExoJS's ownership-driven cleanup.
A Scene owns one for its whole lifetime, exposed as `Scene.track`. An `Application` does not: it creates one for the duration of its constructor, to release the subsystems already built if a later construction step throws (the caller never receives an instance, so `destroy()` is unreachable). Its own `Application.destroy()` runs an explicit ordered teardown instead, because the WebGPU→WebGL2 backend fallback replaces subsystems after construction, which a long-lived scope would not follow.
`track` is idempotent and returns its argument for fluent capture:
```ts const world = scope.track(new PhysicsWorld()); ```
destroy is idempotent and tolerant: every tracked item's `destroy()` is attempted even if an earlier one throws, so a single failure cannot leak the rest. In development the collected errors are rethrown as an `AggregateError` once teardown completes; in production they are swallowed.
A `DestroyScope` is itself Destroyable, so scopes can nest.
new(): DestroyScopedestroy(): voidtrack(item: T): Tdestroyed: booleansize: number