-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
feat: move notifying observers to event dispatcher #44474
feat: move notifying observers to event dispatcher #44474
Conversation
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.
Looks good! I know it is a bit of a work, but could you add in the test plan a video or something showing that the event is working in all the use cases:
- Old Architecture
- New Architecture (with Bridge - for the internal use case)
- New Architecture (with bridgeless)
Thank you so much!
Done ✅ |
One downside I see about it is that we now add the listener on old arch too where it is not used. But it does not seem too problematic I guess? |
Yeah, if nothing in the Old Architecture fires the Out of curiosity, have you tried to remove the pestering code here? |
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Base commit: 93c079b |
Forgot about this one, trying it now. |
Yeah, it works just fine when this line is removed 🚀 I'll remove it then! |
/rebase - this comment automatically rebase on top of main |
Finally back to this! :D |
ce87408
to
34c3ac4
Compare
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
/rebase - this comment automatically rebase on top of main |
@WoLewicki I need to work a little on this as I cannot land it as it is, due to how the internal system works... is it okay for you? |
@cipolleschi yeah no problem, as long as we fix the issue 🚀 |
Summary: Based on the discussion starting here: https://discord.com/channels/514829729862516747/1073566663825432587/1237407161991172157, I suggest moving the call to `_notifyEventDispatcherObserversOfEvent_DEPRECATED` straight to `RCTEventDispatcher.mm`. It was previously in `RCTInstance.mm` which is only relevant on bridgeless mode. We want to mimic the behavior of https://github.com/facebook/react-native/blob/06eea61c19cd730cf0c14a436f042d30791c3f4a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm#L75-L78 but without using `currentBridge` since it is considered bad practice: software-mansion/react-native-reanimated#5497 (comment). ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [CHANGED] - Move `notifyObservers` straight to `RCTEventDispatcher.mm`. Pull Request resolved: facebook#44474 Test Plan: See that example with `stickyHeaders` still works correctly on both bridgeless and bridge mode. Videos with it on https://github.com/facebook/react-native/blob/deee037c62a7d62a349d34db427b14d3560ddf83/packages/rn-tester/js/examples/FlatList/FlatList-stickyHeaders.js example with more items for visibility: - bridgeless: https://github.com/facebook/react-native/assets/32481228/8b78104a-226b-466a-9f32-60ba4ec14100 - bridge: https://github.com/facebook/react-native/assets/32481228/f2ca67cb-578f-45d4-954f-3249c6fa9410 - old arch: https://github.com/facebook/react-native/assets/32481228/7d642923-ddda-4dd3-8f14-c9982a03bc2e Differential Revision: D57097880 Reviewed By: javache Pulled By: cipolleschi
@cipolleschi merged this pull request in f5c888c. |
This pull request was successfully merged by @WoLewicki in f5c888c. When will my fix make it into a release? | How to file a pick request? |
Summary: Based on the discussion starting here: https://discord.com/channels/514829729862516747/1073566663825432587/1237407161991172157, I suggest moving the call to `_notifyEventDispatcherObserversOfEvent_DEPRECATED` straight to `RCTEventDispatcher.mm`. It was previously in `RCTInstance.mm` which is only relevant on bridgeless mode. We want to mimic the behavior of https://github.com/facebook/react-native/blob/06eea61c19cd730cf0c14a436f042d30791c3f4a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm#L75-L78 but without using `currentBridge` since it is considered bad practice: software-mansion/react-native-reanimated#5497 (comment). ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [CHANGED] - Move `notifyObservers` straight to `RCTEventDispatcher.mm`. Pull Request resolved: facebook#44474 Test Plan: See that example with `stickyHeaders` still works correctly on both bridgeless and bridge mode. Videos with it on https://github.com/facebook/react-native/blob/deee037c62a7d62a349d34db427b14d3560ddf83/packages/rn-tester/js/examples/FlatList/FlatList-stickyHeaders.js example with more items for visibility: - bridgeless: https://github.com/facebook/react-native/assets/32481228/8b78104a-226b-466a-9f32-60ba4ec14100 - bridge: https://github.com/facebook/react-native/assets/32481228/f2ca67cb-578f-45d4-954f-3249c6fa9410 - old arch: https://github.com/facebook/react-native/assets/32481228/7d642923-ddda-4dd3-8f14-c9982a03bc2e Reviewed By: javache Differential Revision: D57097880 Pulled By: cipolleschi fbshipit-source-id: de1504e90529fe4f001f44f02ace329386cf7727
Summary:
Based on the discussion starting here: https://discord.com/channels/514829729862516747/1073566663825432587/1237407161991172157, I suggest moving the call to
_notifyEventDispatcherObserversOfEvent_DEPRECATED
straight toRCTEventDispatcher.mm
. It was previously inRCTInstance.mm
which is only relevant on bridgeless mode. We want to mimic the behavior ofreact-native/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
Lines 75 to 78 in 06eea61
currentBridge
since it is considered bad practice: software-mansion/react-native-reanimated#5497 (comment).Changelog:
[IOS] [CHANGED] - Move
notifyObservers
straight toRCTEventDispatcher.mm
.Test Plan:
See that example with
stickyHeaders
still works correctly on both bridgeless and bridge mode.Videos with it on https://github.com/facebook/react-native/blob/deee037c62a7d62a349d34db427b14d3560ddf83/packages/rn-tester/js/examples/FlatList/FlatList-stickyHeaders.js example with more items for visibility:
bridgelessSticky.mov
bridgeSticky.mov
oldarchSticky.mov