SplitScript reference / Language / onDetach
onDetach
lifecycle block
onDetach { ... }
Handles the end of a successfully initialized state-provider attachment.
Runs synchronously once when a logical attachment whose onAttach completed ends, after its provider state, attachment-scoped globals, and pending continuations are cleared. Usually this happens when the host process closes; an emulator provider also detaches when its game mapping disappears, even if the emulator remains open. It does not run when attachment initialization was still pending or rejected through postfix ? or throw, and it never runs for the initial detached state; use setup for one-time script initialization. Process providers and state snapshots are unavailable.
Examples
Use onDetach
onDetach {
timer.pauseGameTime()
}