scheduleOnRuntime
scheduleOnRuntime lets you schedule a worklet function to be executed on a Worker Runtime.
Reference
Code
Code
Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.
function greet(greeting) {
'worklet';
console.log(`${greeting} from the background Worklet Runtime`);
}
const workletRuntime = createWorkletRuntime({ name: 'background' });
scheduleOnRuntime(workletRuntime, greet, 'Hello');
console.log('The RN Runtime continues');
Console 0
No output yet
Output appears here as the code runs.


Type definitions
function scheduleOnRuntime<Args extends unknown[], ReturnValue>(
workletRuntime: WorkletRuntime,
worklet: (...args: Args) => ReturnValue,
...args: Args
): void;
Arguments
workletRuntime
The worklet runtime to schedule the worklet function on.
worklet
A reference to a function you want to execute on the Worker Runtime.
args
Arguments to the function you want to execute on the Worker Runtime.
Remarks
- The worklet function is scheduled on the Worker Runtime's Async Queue
Call table
| Mode | RN Runtime | UI Runtime | Worker Runtime |
|---|---|---|---|
| Bundle Mode | ✅ | ✅ | ✅ |
| Legacy Eval Mode | ✅ | ✅ | ✅ |
Platform compatibility
| Native | Web |
|---|---|
| ✅ | ❌ |