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

Refactor EventComponent logic + add onOwnershipChange callback #15354

Merged
merged 2 commits into from
Apr 9, 2019

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Apr 8, 2019

Note: this PR is for the experimental event API

This PR does a bunch of things. The changes are mostly cosmetic tidy ups that simplify patterns and remove the exposure of internal fiber data structures, but also this PR adds a new feature (onOwnershipChange). Specifically:

  • Further cleans up the responder logic, where instead of tracking fibers, we now track EventComponent instance nodes instead.
  • Highlight the EventComponent instance as being a feature and add necessary Flow typings around it. This means refactoring renderer callbacks to use this object rather than leaking fiber data structures.
  • Adds onOwnershipChange. When a responder module requests ownership, responders can opt into listening for a change in ownership – to allow for cleanup of events. Ownership is tracked via a Set.
  • Refactored handleEventComponent callback in renderers to be two separate callbacks: mountEventComponent and updateEventComponent, so things are more consistent.
  • Adds a test to validate onOwnershipChange working.

@sizebot
Copy link

sizebot commented Apr 8, 2019

ReactDOM: size: 0.0%, gzip: -0.0%

Details of bundled changes.

Comparing: 29fb586...96dd7cb

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.2% +0.1% 892.65 KB 894.13 KB 201.77 KB 201.96 KB UMD_DEV
react-dom.production.min.js 0.0% -0.0% 105.58 KB 105.59 KB 34.2 KB 34.19 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 108.59 KB 108.6 KB 34.8 KB 34.8 KB UMD_PROFILING
react-dom.development.js +0.2% +0.1% 887.27 KB 888.76 KB 200.21 KB 200.4 KB NODE_DEV
react-dom.production.min.js 0.0% -0.0% 105.56 KB 105.57 KB 33.64 KB 33.64 KB NODE_PROD
react-dom.profiling.min.js 0.0% -0.0% 108.68 KB 108.69 KB 34.23 KB 34.23 KB NODE_PROFILING
ReactDOM-dev.js +0.2% +0.1% 913.37 KB 914.85 KB 202.1 KB 202.21 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+0.4% 🔺+0.3% 337.04 KB 338.24 KB 62.09 KB 62.26 KB FB_WWW_PROD
ReactDOM-profiling.js +0.3% +0.3% 343.71 KB 344.91 KB 63.47 KB 63.66 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js +0.2% +0.1% 892.97 KB 894.46 KB 201.91 KB 202.09 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% -0.0% 105.59 KB 105.6 KB 34.2 KB 34.2 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 108.6 KB 108.61 KB 34.81 KB 34.81 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.2% +0.1% 887.6 KB 889.08 KB 200.35 KB 200.53 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% -0.0% 105.58 KB 105.58 KB 33.65 KB 33.65 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js 0.0% -0.0% 108.69 KB 108.7 KB 34.24 KB 34.24 KB NODE_PROFILING
ReactFire-dev.js +0.2% +0.1% 912.55 KB 914.04 KB 202.11 KB 202.25 KB FB_WWW_DEV
ReactFire-prod.js 🔺+0.4% 🔺+0.3% 325.69 KB 326.9 KB 59.77 KB 59.96 KB FB_WWW_PROD
ReactFire-profiling.js +0.4% +0.3% 332.3 KB 333.51 KB 61.14 KB 61.33 KB FB_WWW_PROFILING
react-dom-unstable-new-scheduler.development.js +0.2% +0.1% 885.78 KB 887.26 KB 199.63 KB 199.82 KB NODE_DEV
react-dom-unstable-new-scheduler.production.min.js 0.0% -0.0% 103.65 KB 103.66 KB 33.13 KB 33.12 KB NODE_PROD
react-dom-unstable-new-scheduler.profiling.min.js 0.0% -0.0% 106.99 KB 107 KB 34.01 KB 34.01 KB NODE_PROFILING
ReactDOMNewScheduler-dev.js +0.2% +0.1% 913.4 KB 914.88 KB 202.1 KB 202.21 KB FB_WWW_DEV
ReactDOMNewScheduler-prod.js 🔺+0.4% 🔺+0.3% 331 KB 332.2 KB 61.64 KB 61.8 KB FB_WWW_PROD
ReactDOMNewScheduler-profiling.js +0.3% +0.3% 336.57 KB 337.64 KB 62.64 KB 62.8 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 10.52 KB 10.52 KB 3.9 KB 3.89 KB UMD_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.69 KB 10.69 KB 3.67 KB 3.67 KB UMD_PROD
react-dom-server.browser.development.js 0.0% -0.0% 136.52 KB 136.52 KB 35.92 KB 35.91 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.24 KB 19.24 KB 7.24 KB 7.24 KB UMD_PROD
react-dom-server.browser.development.js 0.0% -0.0% 132.65 KB 132.65 KB 34.98 KB 34.98 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.17 KB 19.17 KB 7.23 KB 7.23 KB NODE_PROD
ReactDOMServer-prod.js 0.0% -0.0% 47.7 KB 47.7 KB 10.95 KB 10.95 KB FB_WWW_PROD
react-dom-server.node.development.js 0.0% 0.0% 134.59 KB 134.59 KB 35.53 KB 35.53 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% -0.0% 20.03 KB 20.03 KB 7.53 KB 7.53 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.2% 1.05 KB 1.05 KB 638 B 637 B NODE_PROD
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 3.74 KB 3.74 KB 1.43 KB 1.43 KB NODE_DEV

Generated by 🚫 dangerJS

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

this does feel like it has more clarity and less futzing with fibers. approved.

@trueadm trueadm merged commit aece811 into facebook:master Apr 9, 2019
@trueadm trueadm deleted the ownership-callback branch April 9, 2019 11:47
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.

None yet

4 participants