-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Autoworkletize callbacks in Layout Animations #4652
Autoworkletize callbacks in Layout Animations #4652
Conversation
…-layout-animations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need also tests for class instance, for example - new FadeIn().withCallback()
and for longer chaining like - FadeIn.duration().springify().withCallback()
, FadeIn.duration().withCallback().springify()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think tests with new
keywords are necessary. Moreover, I think they would be misleading as it's not a case that's in any way considered in our plugin. If we take a look at the AST tree:
Everything is wrapped in NewExpression
. So unless babel ever decides to change how it parses the tree we shouldn't worry about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgor to add () to constructor here, therefore objects with new operator actually have to be handled 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering if it is possible to create tests that will check if all names from EntryExitAnimations
, LayoutTransitions
, BaseAnimationsChainableMethods
, and DefaultTransitionChainableMethods
are still relevant. I mean, how to detect that someone changes the name of a class/method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to do it but it seems very complicated. TypeScript makes it difficult enough to import (actually require) anything outside plugin's root directory and forces us to use require, therefore we would need to use require on generated lib files 😵
<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please follow the template so that the reviewers can easily understand what the code changes affect. --> ## Summary Currently we support auto-workletizing callbacks with method chaining for `react-native-gesture-handler`: ```TS Gesture.Tap().onBegin(() => { // will be automatically workletized ... }); ``` This pull request adds similar functionality to Layout Animations and their `withCallback` method so the `worklet` directive is no longer necessary. ```TS FadeIn.duration(400).withCallback(() => { // will be automatically workletized now ... }); ``` ## Test plan A new test suite was added to plugin's tests. --------- Co-authored-by: kacperkapusciak <kacper.kapusciak@swmansion.com>
Summary
Currently we support auto-workletizing callbacks with method chaining for
react-native-gesture-handler
:This pull request adds similar functionality to Layout Animations and their
withCallback
method so theworklet
directive is no longer necessary.Test plan
A new test suite was added to plugin's tests.