Skip to main content

scheduleOnRuntimeWithId
Available from 0.8.0

scheduleOnRuntimeWithId is a variant of scheduleOnRuntime where you use the runtime's id instead of the runtime object. It's useful when you don't have access to the runtime object, but you know its id.

Reference

import { scheduleOnRuntimeWithId, createWorkletRuntime } from 'react-native-worklets';

const workletRuntime = createWorkletRuntime({ name: 'background' });

scheduleOnRuntimeWithId(workletRuntime.runtimeId, (greeting: string) => {
console.log(`${greeting} from the background Worklet Runtime`);
}, 'Hello');

Type definitions

function scheduleOnRuntimeWithId<Args extends unknown[], ReturnValue>(
runtimeId: number,
worklet: (...args: Args) => ReturnValue,
...args: Args
): void;

Arguments

runtimeId

The id of the Worklet Runtime to schedule the worklet on. You can get the id from the runtime object by accessing its runtimeId property.

worklet

A reference to a function you want to execute on the Worklet Runtime.

args

Arguments to the function you want to execute on the Worklet Runtime.

Remarks

  • The worklet is scheduled on the Worker Runtime's Async Queue
  • You can target the UI Runtime by passing UIRuntimeId as the runtime id.

Call table

Bundle ModeRN RuntimeUI RuntimeWorker Runtime
Enabled
Disabled

What does it mean?

Platform compatibility

NativeWeb