Skip to content

Commit ccae55e

Browse files
chore: Describe isWorkletRuntime behavior on different runtimes (software-mansion#6692)
## Summary @latekvo told me it's poorly documented so I updated it ## Test plan --------- Co-authored-by: Bartłomiej Błoniarz <[email protected]>
1 parent 63feb1f commit ccae55e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/commonTypes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,8 @@ export type WorkletFunction<
408408
*
409409
* ### Maintainer note
410410
*
411-
* This function works well on the JS thread performance-wise, since the JIT can
412-
* inline it. However, on other threads it will not get optimized and we will
413-
* get a function call overhead. We want to change it in the future, but it's
414-
* not feasible at the moment.
411+
* This function is supposed to be used only in the React Runtime. It always
412+
* returns `false` in Worklet Runtimes.
415413
*/
416414
export function isWorkletFunction<
417415
Args extends unknown[] = unknown[],
@@ -421,7 +419,9 @@ export function isWorkletFunction<
421419
'worklet';
422420
// Since host objects always return true for `in` operator, we have to use dot notation to check if the property exists.
423421
// See https://github.com/facebook/hermes/blob/340726ef8cf666a7cce75bc60b02fa56b3e54560/lib/VM/JSObject.cpp#L1276.
422+
424423
return (
424+
// `__workletHash` isn't extracted in Worklet Runtimes.
425425
typeof value === 'function' &&
426426
!!(value as unknown as Record<string, unknown>).__workletHash
427427
);

0 commit comments

Comments
 (0)