← Application composition

App.Context

luastra/app

App.Context is an exported, statically checked data contract of luastra/app. Its exact declaration documents the fields or alternatives accepted at the module boundary and is erased after Luau analysis.

Before you use it

Add luastra/app to this module's dependencies in luastra.json, then import it with require("luastra/app"). Return exactly one App.compose instance from the entry module. Feature IDs must be disjoint lowercase paths, and a feature must claim each asynchronous request ID before its completion can be routed.

How it fits

App types describe the root composition contract, feature hooks, request-ownership context, diagnostics, and returned instance. Static types are erased after analysis.

When to use it

Use App.Context when annotating values that cross the public luastra/app boundary or when exporting helpers built on that module. The type documents the exact checked shape and prevents unrelated tables from being substituted accidentally.

Fields or definition

ParameterType / valuesDescription
idstringStable identifier used to correlate or address this value across operations.
claim(requestId: number, purpose: string) -> numberCallable claim member exposed by App.Context; invoke it through the owning contract rather than replacing internal state.
cancel(requestId: number) -> booleanCallable cancel member exposed by App.Context; invoke it through the owning contract rather than replacing internal state.
owns(requestId: number, generation: number) -> booleanCallable owns member exposed by App.Context; invoke it through the owning contract rather than replacing internal state.
activeCount() -> numberCallable activeCount member exposed by App.Context; invoke it through the owning contract rather than replacing internal state.

What happens next

A checked application-composition annotation that matches the exported contract.

Failures and fixes

Duplicate or overlapping feature IDs, invalid event bounds, duplicate request ownership, and malformed compose options fail immediately. Late, cancelled, unknown, or post-dispose completions are suppressed or delegated only through the explicitly configured root path.

Availability

Public-source alpha composition API in 0.5.0-alpha; host-independent except for the capabilities used by composed features.

Exact declaration

export type Context = {
    id: string,
    claim: (requestId: number, purpose: string) -> number,
    cancel: (requestId: number) -> boolean,
    owns: (requestId: number, generation: number) -> boolean,
    activeCount: () -> number,
}

Complete inventory

View all pages in Application composition
Next: App.Feature →