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

introduce Fantom.dispatchNativeStateUpdate #48802

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sammy-SC
Copy link
Contributor

Summary:
changelog: [internal]

Introduces a mechanism to fake C++ state update from JavaScript for testing in Fantom.

One problem with approach in this diff is use of folly::dynamic. To make it work, folly::dynamic is no longer Android only.
iOS and other platforms are not paying extra cost for folly::dynamic being included because they all already have it.

The alternative approach would be to introduce a component specific interface to NativeFantom module so state in ScrollView, TextInput and Image can be manipulated. On the flip side, this is a very flexible solution.

In the future, we might want to introduce Fantom wrappers around ScrollView and TextInput that would be flow typed in tests. They would also make sure that changing ScrollView.contentOffset always triggers both onScroll and state update.

Differential Revision: D68418535

Summary:
changelog: [internal]


Adds new method `dispatchNativeEvent` to Fantom give option to dispatch fake native events.

The API is expanded in subsequent diffs. The version introduced in this diff supports only dispatching event without payload and without any options.

Differential Revision: D68331986
Summary:
changelog: [internal]

Add payload argument to Fantom.dispatchNativeEvent. For example, in `TextInput.onChange` event, new value of input field must be present in the event payload.

Reviewed By: rubennorte

Differential Revision: D68410469
Summary:
changelog: [internal]

add event category argument to Fantom.dispatchNativeEvent.

This gives tests option to control whether an event is continuous, discrete etc.

Differential Revision: D68413879
Summary:
changelog: [internal]

Adds isUnique option to Fantom.dispatchNativeEvent.

isUnique controls whether only the last event of the same type and target is dispatched to JavaScript or all events are queued and dispatched.

Differential Revision: D68416157
Summary:
changelog: [internal]

Introduces a mechanism to fake C++ state update from JavaScript for testing in Fantom.

One problem with approach in this diff is use of folly::dynamic. To make it work, folly::dynamic is no longer Android only.
iOS and other platforms are not paying extra cost for folly::dynamic being included because they all already have it.

The alternative approach would be to introduce a component specific interface to NativeFantom module so state in ScrollView, TextInput and Image can be manipulated. On the flip side, this is a very flexible solution.

In the future, we might want to introduce Fantom wrappers around ScrollView and TextInput that would be flow typed in tests. They would also make sure that changing ScrollView.contentOffset always triggers both onScroll and state update.

Differential Revision: D68418535
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jan 20, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68418535

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants