UNPKG

2.94 kBTypeScriptView Raw
1import type { WorkletFunction } from './commonTypes';
2export declare function setupMicrotasks(): void;
3export declare const callMicrotasks: () => void;
4/**
5 * Lets you asynchronously run
6 * [workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize)
7 * functions on the [UI
8 * thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
9 *
10 * This method does not schedule the work immediately but instead waits for
11 * other worklets to be scheduled within the same JS loop. It uses
12 * queueMicrotask to schedule all the worklets at once making sure they will run
13 * within the same frame boundaries on the UI thread.
14 *
15 * @param fun - A reference to a function you want to execute on the [UI
16 * thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI)
17 * from the [JavaScript
18 * thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
19 * @returns A function that accepts arguments for the function passed as the
20 * first argument.
21 * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI
22 */
23export declare function runOnUI<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): (...args: Args) => void;
24export declare function executeOnUIRuntimeSync<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): (...args: Args) => ReturnValue;
25export declare function runOnUIImmediately<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): WorkletFunction<Args, ReturnValue>;
26type ReleaseRemoteFunction<Args extends unknown[], ReturnValue> = {
27 (...args: Args): ReturnValue;
28};
29type DevRemoteFunction<Args extends unknown[], ReturnValue> = {
30 __remoteFunction: (...args: Args) => ReturnValue;
31};
32type RemoteFunction<Args extends unknown[], ReturnValue> = ReleaseRemoteFunction<Args, ReturnValue> | DevRemoteFunction<Args, ReturnValue>;
33/**
34 * Lets you asynchronously run
35 * non-[workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize)
36 * functions that couldn't otherwise run on the [UI
37 * thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#ui-thread).
38 * This applies to most external libraries as they don't have their functions
39 * marked with "worklet"; directive.
40 *
41 * @param fun - A reference to a function you want to execute on the JavaScript
42 * thread from the UI thread.
43 * @returns A function that accepts arguments for the function passed as the
44 * first argument.
45 * @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnJS
46 */
47export declare function runOnJS<Args extends unknown[], ReturnValue>(fun: ((...args: Args) => ReturnValue) | RemoteFunction<Args, ReturnValue> | WorkletFunction<Args, ReturnValue>): (...args: Args) => void;
48export {};
49//# sourceMappingURL=threads.d.ts.map
\No newline at end of file