Runtime types
Types shared by several @roku-sdk/runtime exports, or used by none of them directly
import type {
DeviceInfoEventsHook,
} from "@roku-sdk/runtime/device-info-events";
import type { InputEventsHook } from "@roku-sdk/runtime/input";
import type { LifecycleEventsHook } from "@roku-sdk/runtime/lifecycle";Each is documented here once and linked from every page that uses it.
Types
DeviceInfoEventsHook
An object of accessors for device-level events: the UI resolution, screensaver exit, network link status, low-memory warnings and internet connectivity.
Each accessor is null until its first event. The hooks do not return this type: to subscribe to these events, use useUiResolution for the resolution and useDeviceInfoEvents for the others, which reports screensaver exits, link changes and internet changes as counters.
type DeviceInfoEventsHook = {
uiResolution: Accessor<UIResolution | null>;
screensaverExited: Accessor<boolean | null>;
linkStatus: Accessor<boolean | null>;
lowGeneralMemory: Accessor<string | null>;
internetStatus: Accessor<boolean | null>;
};| Name | Type | Description |
|---|---|---|
internetStatus | Accessor<boolean | null> | Whether the device can reach the internet, or null before the first report. |
linkStatus | Accessor<boolean | null> | Whether the device's network link is up, or null before the first report. |
lowGeneralMemory | Accessor<string | null> | The device's general memory level: "NORMAL", "LOW", "CRITICAL" or "UNKNOWN", or null before the first report. |
screensaverExited | Accessor<boolean | null> | Whether the screensaver has exited, as last reported by the runtime, or null before the first report. |
uiResolution | Accessor<UIResolution | null> | The device's current UI resolution, or null until it is known. |
InputEventsHook
Return type for the useInput hook.
Provides reactive access to input events from the Roku runtime. Both properties are SolidJS Accessors that update when input events occur.
Example
const input = useInput();
createEffect(() => {
const params = input.inputParams();
if (params) {
console.log('Input received:', params);
}
});// Handle voice input and report status
const input = useInput();
createEffect(() => {
const voiceParams = input.voiceInputParams();
if (voiceParams) {
// Process voice command...
const success = input.updateVoiceInputStatus({
id: voiceParams.id,
status: 'success'
});
}
});type InputEventsHook = {
inputParams: Accessor<InputParams | null>;
voiceInputParams: Accessor<VoiceInputParams | null>;
updateVoiceInputStatus: (params: { id: number; status: VoiceHandledStatus }) => boolean;
};| Name | Type | Description |
|---|---|---|
inputParams | Accessor<InputParams | null> | Reactive accessor for standard input parameters. Returns null when no input event is pending. |
updateVoiceInputStatus | (params: { id: number; status: VoiceHandledStatus }) => boolean | Method to notify the device that a voice request has been handled. |
voiceInputParams | Accessor<VoiceInputParams | null> | Reactive accessor for voice input parameters. Returns null when no voice input event is pending. |
LifecycleEventsHook
Return type for the useLifecycle hook.
Provides reactive access to app lifecycle events (suspend/resume) from the Roku runtime. Both properties are SolidJS Accessors that update when lifecycle events occur.
Example
const lifecycle = useLifecycle();
createEffect(() => {
const suspend = lifecycle.suspendParams();
if (suspend) {
console.log('Suspending due to:', suspend.lastSuspendOrResumeReason);
// Update UI for suspend
lifecycle.completeSuspend();
}
});// Handle resume with deep link parameters
const lifecycle = useLifecycle();
createEffect(() => {
const resume = lifecycle.resumeParams();
if (resume) {
console.log('Resuming due to:', resume.lastSuspendOrResumeReason);
if (resume.launchParams.source === 'deeplink') {
handleDeepLink(resume.launchParams);
}
lifecycle.completeResume();
}
});type LifecycleEventsHook = {
suspendParams: Accessor<SuspendParams | null>;
resumeParams: Accessor<ResumeParams | null>;
completeSuspend: () => void;
completeResume: () => void;
};| Name | Type | Description |
|---|---|---|
completeResume | () => void | Method to explicitly signal that resume handling is complete. |
completeSuspend | () => void | Method to explicitly signal that suspend handling is complete and runtime should freeze execution. |
resumeParams | Accessor<ResumeParams | null> | Reactive accessor for resume event parameters. Returns null when no resume event is pending. |
suspendParams | Accessor<SuspendParams | null> | Reactive accessor for suspend event parameters. Returns null when no suspend event is pending. |
Updated about 3 hours ago