Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isWorklet function #4894

Merged
merged 6 commits into from
Feb 12, 2024
Merged

Add isWorklet function #4894

merged 6 commits into from
Feb 12, 2024

Conversation

tomekzaw
Copy link
Member

@tomekzaw tomekzaw commented Aug 7, 2023

Summary

This PR adds isWorklet function which is meant to be used internally as well as by other libraries in order to check whether the input value is a worklet (i.e. is a function with __workletHash property added by Reanimated Babel plugin).

Once worklet types are fixed, isWorklet should mark the input value as worklet, i.e. we'll need to change its signature to export function isWorklet(value: unknown): value is WorkletType.

EDIT from @tjzel:

In order to be able to use the new function isWorklet properly I had to fix a bunch of types with regard to worklet types.

Test plan

Check that TS CI passes and all the ifs with .__workletHash were changed properly.

@tomekzaw tomekzaw requested a review from tjzel August 7, 2023 12:02
src/reanimated2/utils.ts Outdated Show resolved Hide resolved
@tjzel tjzel marked this pull request as ready for review February 5, 2024 13:16
Copy link
Collaborator

@tjzel tjzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me looks good hehe

@tjzel tjzel requested a review from Latropos February 5, 2024 13:16
Copy link
Member Author

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, let's promote isWorklet function to a worklet and use it in the UI runtime code as well.

src/reanimated2/commonTypes.ts Show resolved Hide resolved
src/reanimated2/hook/useAnimatedProps.ts Show resolved Hide resolved
@tjzel
Copy link
Collaborator

tjzel commented Feb 6, 2024

Waits to be merged after 3.7.0 release.

@tjzel tjzel added this pull request to the merge queue Feb 12, 2024
Merged via the queue into main with commit 8a95e6b Feb 12, 2024
7 checks passed
@tjzel tjzel deleted the @tomekzaw/is-worklet branch February 12, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants