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 part of the event responder system for experimental event API #15179

Merged
merged 13 commits into from
Mar 26, 2019

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Mar 21, 2019

Note: this is for an experimental event API that we're testing out internally at Facebook.

This PR adds logic to handle triggering event responders from events that are listened to at a top level. This follows on from previous PRs:

This PR also adds tests that validate the triggering of event responder handleEvent function.

@threepointone

This comment has been minimized.

@trueadm
Copy link
Contributor Author

trueadm commented Mar 22, 2019

I've added more test coverage and added comments around some of the logic involved in handling the active event component fibers.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

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

You have CI build errors which cover up the file size changes (if any).

this._nonDiscreteEvents = [];
}

DOMEventResponderContext.prototype.isPassive = function(): boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we avoid using methods on prototypes and instead call it with an argument - like we do in the newer code? function isPassive(context: DOMEventResponderContext){ ... } Methods are much harder to analyze for GCC and requires a virtual dispatch for every call. With stand alone functions we can feel good about getting automatic inlining and DCE with use of future feature flags and such.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

context is passed to the event responder module so that the user can call isPassive etc without having to know about the React internals. I thought about exposing these functions via a public API on React, but that felt like over-kill, especially as the responder modules are external to React.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool. I don't fully see how everything will fit together. We can come back to this later once more stuff is in place.

packages/react-dom/src/client/ReactDOMHostConfig.js Outdated Show resolved Hide resolved
@sizebot
Copy link

sizebot commented Mar 26, 2019

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: 78f2775...ea86b4b

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.6% +0.6% 804.45 KB 809.3 KB 182.3 KB 183.48 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 105.09 KB 105.11 KB 33.96 KB 33.97 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 108.06 KB 108.08 KB 34.62 KB 34.63 KB UMD_PROFILING
react-dom.development.js +0.6% +0.7% 798.84 KB 803.69 KB 180.68 KB 181.86 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 105.06 KB 105.08 KB 33.47 KB 33.47 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 108.17 KB 108.19 KB 34.07 KB 34.08 KB NODE_PROFILING
ReactDOM-dev.js +0.6% +0.7% 823.23 KB 828.29 KB 182.26 KB 183.54 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+1.1% 🔺+1.3% 324.92 KB 328.59 KB 59.7 KB 60.49 KB FB_WWW_PROD
ReactDOM-profiling.js +1.2% +1.3% 336.35 KB 340.33 KB 61.84 KB 62.63 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js +0.6% +0.6% 804.79 KB 809.65 KB 182.44 KB 183.62 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 105.1 KB 105.12 KB 33.97 KB 33.98 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 108.08 KB 108.1 KB 34.63 KB 34.63 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.6% +0.7% 799.18 KB 804.04 KB 180.82 KB 182 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 105.08 KB 105.1 KB 33.48 KB 33.48 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 108.18 KB 108.2 KB 34.07 KB 34.08 KB NODE_PROFILING
ReactFire-dev.js +0.6% +0.7% 822.44 KB 827.5 KB 182.13 KB 183.41 KB FB_WWW_DEV
ReactFire-prod.js 🔺+1.2% 🔺+1.4% 313.48 KB 317.25 KB 57.36 KB 58.16 KB FB_WWW_PROD
ReactFire-profiling.js +1.2% +1.3% 324.86 KB 328.84 KB 59.39 KB 60.17 KB FB_WWW_PROFILING
react-dom-test-utils.development.js 0.0% -0.0% 47.49 KB 47.49 KB 12.98 KB 12.98 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.1% 9.95 KB 9.95 KB 3.66 KB 3.65 KB UMD_PROD
react-dom-test-utils.development.js 0.0% -0.0% 47.21 KB 47.21 KB 12.91 KB 12.91 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 9.73 KB 9.73 KB 3.59 KB 3.59 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.53 KB 60.53 KB 15.8 KB 15.8 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.2 KB 60.2 KB 15.67 KB 15.67 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.42 KB 10.42 KB 3.57 KB 3.56 KB NODE_PROD
react-dom-server.browser.development.js 0.0% -0.0% 133.68 KB 133.68 KB 35.37 KB 35.37 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 18.93 KB 18.93 KB 7.14 KB 7.14 KB UMD_PROD
react-dom-server.browser.development.js 0.0% -0.0% 129.81 KB 129.81 KB 34.43 KB 34.43 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 18.86 KB 18.86 KB 7.14 KB 7.14 KB NODE_PROD
ReactDOMServer-dev.js 0.0% -0.0% 132.15 KB 132.15 KB 34.19 KB 34.19 KB FB_WWW_DEV
react-dom-server.node.development.js 0.0% -0.0% 131.75 KB 131.75 KB 34.97 KB 34.97 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 19.72 KB 19.72 KB 7.44 KB 7.44 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.66 KB 3.66 KB 1.45 KB 1.45 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.21 KB 1.21 KB 706 B 705 B UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1.05 KB 1.05 KB 637 B 636 B NODE_PROD
react-dom-unstable-fizz.node.production.min.js 0.0% -0.1% 1.1 KB 1.1 KB 667 B 666 B NODE_PROD

Generated by 🚫 dangerJS

this._nonDiscreteEvents = [];
}

DOMEventResponderContext.prototype.isPassive = function(): boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool. I don't fully see how everything will fit together. We can come back to this later once more stuff is in place.

packages/react-dom/src/events/DOMEventResponderSystem.js Outdated Show resolved Hide resolved
@trueadm
Copy link
Contributor Author

trueadm commented Mar 26, 2019

I spoke to @sebmarkbage and he was happy with getting this PR in so I'm merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants