Resource.ReadSnapshot
luastra/resourceResource.ReadSnapshot is an exported, statically checked data contract of luastra/resource. 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/resource to this module's dependencies in luastra.json, then import it with require("luastra/resource"). Create each controller once outside app.render. Record the exact ticket returned by begin, correlate it with the host RequestId, and settle only that ticket from app.resolve or another admitted completion boundary.
How it fits
Resource types describe read and mutation states, immutable snapshots, generation tickets, optimistic callbacks, and application-owned errors.
When to use it
Use Resource.ReadSnapshot when annotating values that cross the public luastra/resource 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
| Parameter | Type / values | Description |
|---|---|---|
| status | ReadStatus | Checked status field of Resource.ReadSnapshot; its exact admitted type is ReadStatus. |
| value | T? | Validated value available on the successful result branch. |
| error | Error? | Bounded failure information, or nil on the successful branch. |
| requestId | number? | Checked requestId field of Resource.ReadSnapshot; its exact admitted type is number?. |
| generation | number | Checked generation field of Resource.ReadSnapshot; its exact admitted type is number. |
| invalidated | boolean | Checked invalidated field of Resource.ReadSnapshot; its exact admitted type is boolean. |
| stale | boolean | Checked stale field of Resource.ReadSnapshot; its exact admitted type is boolean. |
What happens next
A checked resource-state annotation for one explicit asynchronous workflow.
Failures and fixes
Invalid options and programmer contract violations fail immediately. A stale ticket returns false without overwriting current state. Translate provider failures to bounded Resource.Error codes and keep raw messages, payloads, tokens, and credentials outside the controller.
Availability
Public-source alpha state API in 0.5.0-alpha; host-independent and designed to compose with any asynchronous capability.
Exact declaration
export type ReadSnapshot<T> = {
status: ReadStatus,
value: T?,
error: Error?,
requestId: number?,
generation: number,
invalidated: boolean,
stale: boolean,
}