Skip to main content
Version: Unreleased

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');

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​

ModeRN RuntimeUI RuntimeWorker Runtime
Bundle Mode✅✅✅
Legacy Eval Mode✅✅✅

What does it mean?

Platform compatibility​

NativeWeb
✅❌