SplitScript reference / Language / onAttach
onAttach
lifecycle block
onAttach { ... }
Initializes one state-provider attachment.
This action is implicitly suspending and owns attachment-lifetime cancellation for await and retry continuations. It is also an implicit error boundary: postfix ? or throw rejects this attachment, keeps its host process inert until it closes, and never runs onDetach for the incomplete attachment. A bare global assigned on every successful path becomes attachment-scoped and may select conditional state and managed class fields. Attachment-scoped globals are frozen after this action completes. Emulator providers run this action again when a newly discovered game mapping replaces one that disappeared without closing the emulator.
Examples
Use onAttach
onAttach {
let module = await process.module("GameAssembly.dll")
}
Related
| Symbol | Description |
|---|---|
| state | Declares process attachment and persistent watched state. |
| conditional fields | Declares fields whose availability follows an ordinary enum value. |
| await | Waits for an asynchronous value and yields its result. |
| retry | Retries synchronous fallible work until it succeeds. |
| ? | Propagates a T! error. |
| throw | Transfers an error to the nearest failure boundary. |
| onStateReady | Initializes one committed state snapshot. |