-
Notifications
You must be signed in to change notification settings - Fork 47k
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
[RN] Consolidate eventTypes registry with view configs #12556
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,50 @@ import type { | |
|
||
import invariant from 'fbjs/lib/invariant'; | ||
|
||
// Event configs | ||
export const customBubblingEventTypes = {}; | ||
export const customDirectEventTypes = {}; | ||
export const eventTypes = {}; | ||
|
||
const viewConfigCallbacks = new Map(); | ||
const viewConfigs = new Map(); | ||
|
||
function processEventTypes( | ||
viewConfig: ReactNativeBaseComponentViewConfig, | ||
): void { | ||
const {bubblingEventTypes, directEventTypes} = viewConfig; | ||
|
||
if (__DEV__) { | ||
if (bubblingEventTypes != null && directEventTypes != null) { | ||
for (const topLevelType in directEventTypes) { | ||
invariant( | ||
bubblingEventTypes[topLevelType] == null, | ||
'Event cannot be both direct and bubbling: %s', | ||
topLevelType, | ||
); | ||
} | ||
} | ||
} | ||
|
||
if (bubblingEventTypes != null) { | ||
for (const topLevelType in bubblingEventTypes) { | ||
if (customBubblingEventTypes[topLevelType] == null) { | ||
eventTypes[topLevelType] = customBubblingEventTypes[topLevelType] = | ||
bubblingEventTypes[topLevelType]; | ||
} | ||
} | ||
} | ||
|
||
if (directEventTypes != null) { | ||
for (const topLevelType in directEventTypes) { | ||
if (customDirectEventTypes[topLevelType] == null) { | ||
eventTypes[topLevelType] = customDirectEventTypes[topLevelType] = | ||
directEventTypes[topLevelType]; | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Registers a native view/component by name. | ||
* A callback is provided to load the view config from UIManager. | ||
|
@@ -49,6 +90,7 @@ export function get(name: string): ReactNativeBaseComponentViewConfig { | |
); | ||
viewConfigCallbacks.set(name, null); | ||
viewConfig = callback(); | ||
processEventTypes(viewConfig); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what lets us avoid exposing ReactNativeBridgeEventPlugin. |
||
viewConfigs.set(name, viewConfig); | ||
} else { | ||
viewConfig = viewConfigs.get(name); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
scripts/rollup/shims/react-native/ReactNativeBridgeEventPlugin.js
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We can also delete the forwarding
scripts/rollup/shims/react-native/ReactNativeBridgeEventPlugin.js
now?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.
Should we just get rid of the
ReactNativeBridgeEventPlugin
entirely now and just moveextractEvents
over into the view config registry as well?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.
Good catch on the shim. I'll delete it.