Skip to main content
Defined in: packages/common/src/context/context.type.ts:13 Read-only application state plus the actions available to affect it.

Remarks

AppContext deliberately exposes no setters — mutation only happens internally, inside @nanoforge-dev/core. Game code and libraries can read state and call actions, but can never reach into and directly overwrite engine-owned state.

Properties

delta

readonly delta: number
Defined in: packages/common/src/context/context.type.ts:19 Elapsed time in milliseconds since the last tick. Does not advance while paused.

isPaused

readonly isPaused: boolean
Defined in: packages/common/src/context/context.type.ts:17 Whether the tick loop is currently paused (no library’s __run is called while paused).

isRunning

readonly isRunning: boolean
Defined in: packages/common/src/context/context.type.ts:15 Whether the engine’s tick loop is currently running.

libraries

readonly libraries: readonly string[]
Defined in: packages/common/src/context/context.type.ts:23 Keys of the registered libraries.

tickRate

readonly tickRate: number
Defined in: packages/common/src/context/context.type.ts:21 Configured ticks-per-second for the run loop.

Methods

callHook()

callHook(name, …args): Promise<void>
Defined in: packages/common/src/context/context.type.ts:44 Calls an optional hook on every library that has it, in run order, one after the other.

Parameters

name
string Name of the method to call.
args
…unknown[] Arguments handed to it.

Returns

Promise<void>

Remarks

Lets a library define a lifecycle step of its own for the others (a method named like the built-in hooks, e.g. __myLibraryReady) without the engine knowing about it.

observeTicks()

observeTicks(observer): () => void
Defined in: packages/common/src/context/context.type.ts:50 Observes the tick loop.

Parameters

observer
TickObserver

Returns

A function that stops observing. () => void

requestPause()

requestPause(): void
Defined in: packages/common/src/context/context.type.ts:27 Pauses the tick loop: every library’s __run is skipped until resumed.

Returns

void

requestResume()

requestResume(): void
Defined in: packages/common/src/context/context.type.ts:29 Resumes a paused tick loop.

Returns

void

requestStep()

requestStep(): void
Defined in: packages/common/src/context/context.type.ts:31 Runs exactly one tick (__run of every library) while paused.

Returns

void

requestStop()

requestStop(): void
Defined in: packages/common/src/context/context.type.ts:25 Requests that the tick loop stop after the current tick.

Returns

void