UNPKG

react-native-worklets

Version:
59 lines 3.24 kB
import type { WorkletFunction, WorkletRuntime, WorkletRuntimeConfig } from './types'; /** * Lets you create a new JS runtime which can be used to run worklets possibly * on different threads than JS or UI thread. * * @param config - Runtime configuration object - {@link WorkletRuntimeConfig}. * @returns WorkletRuntime which is a * `jsi::HostObject<worklets::WorkletRuntime>` - {@link WorkletRuntime} * @see https://docs.swmansion.com/react-native-worklets/docs/threading/createWorkletRuntime/ */ export declare function createWorkletRuntime(config?: WorkletRuntimeConfig): WorkletRuntime; /** * @deprecated Please use the new config object signature instead: * `createWorkletRuntime({ name, initializer })` * * Lets you create a new JS runtime which can be used to run worklets possibly * on different threads than JS or UI thread. * @param name - A name used to identify the runtime which will appear in * devices list in Chrome DevTools. * @param initializer - An optional worklet that will be run synchronously on * the same thread immediately after the runtime is created. * @returns WorkletRuntime which is a * `jsi::HostObject<worklets::WorkletRuntime>` - {@link WorkletRuntime} * @see https://docs.swmansion.com/react-native-worklets/docs/threading/createWorkletRuntime/ */ export declare function createWorkletRuntime(name?: string, initializer?: () => void): WorkletRuntime; /** * Lets you asynchronously run a * [worklet](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/glossary#worklet) * on a [Worker * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime). * * Check * {@link https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds} * for more information about the different runtime kinds. * * - The worklet is scheduled on the Worker Runtime's [Async * Queue](https://github.com/software-mansion/react-native-reanimated/blob/main/packages/react-native-worklets/Common/cpp/worklets/RunLoop/AsyncQueue.h) * - The function cannot be scheduled on the Worker Runtime from [UI * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#ui-runtime) * or another [Worker * Runtime](https://docs.swmansion.com/react-native-worklets/docs/fundamentals/runtimeKinds#worker-runtime), * unless the [Bundle * Mode](https://docs.swmansion.com/react-native-worklets/docs/experimental/bundleMode) * is enabled. * * @param workletRuntime - The runtime to schedule the worklet on. * @param worklet - The worklet to schedule. * @param args - The arguments to pass to the worklet. * @returns The return value of the worklet. */ export declare function scheduleOnRuntime<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue, ...args: Args): void; /** * @deprecated Use `scheduleOnRuntime` instead. * * Schedule a worklet to execute on the background queue. */ export declare function runOnRuntime<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue): WorkletFunction<Args, ReturnValue>; //# sourceMappingURL=runtimes.native.d.ts.map