Skip to main content

scheduleOnRuntime

scheduleOnRuntime lets you schedule a worklet to be executed on a Worker Runtime.

Reference

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

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

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

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 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 is scheduled on the Worker Runtime's Async Queue

Call table

Bundle ModeRN RuntimeUI RuntimeWorker Runtime
Enabled
Disabled

What does it mean?

Platform compatibility

NativeWeb