Skip to content

Conversation

@acoates-ms
Copy link
Contributor

@acoates-ms acoates-ms commented Aug 9, 2024

Description

In a recent integration RN core added support for module specs to have EventEmitters. This modifies our REACT_EVENT macro to use the new EventEmitters. These new EventEmitters work slightly differently than our previous REACT_EVENT macro, and only work on TurboModules. To avoid making the new behavior a breaking change, we will only use the new behavior when the module uses a new REACT_TURBO_MODULE macro instead of REACT_MODULE. This allows us to also modify the behavior of AddAttributedModules to always register those modules as TurboModules rather than NativeModules. Which provides a more incremental way of adopting TurboModules than the previous change of a bool param on AddAttributedModules which made all the attributed modules TurboModules.

I also updated the codegen to generate new native spec files that will verify that you have a REACT_EVENT for every EventEmitter decalred in the JS spec file. The current implementation does not verify the arguments to the function aligns with the JS spec. That can be added in a subsequent change.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Why

What is the motivation for this change? Add a few sentences describing the context and overall goals of the pull request's commits.

Resolves #13532

What

What changes were made to the codebase to solve the bug, add the functionality, etc. that you specified above.

Screenshots

Add any relevant screen captures here from before or after your changes.

Testing

Uncommented the code that runs this in RNTester and verified that the events fire correctly.

Changelog

Yes

Microsoft Reviewers: Open in CodeFlow

@acoates-ms acoates-ms requested review from a team as code owners August 9, 2024 00:10
@microsoft-github-policy-service microsoft-github-policy-service bot added Area: Turbo Modules Parity: React Native RNW does not look or behave like upstream RN platforms New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Turbo Modules New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric Parity: React Native RNW does not look or behave like upstream RN platforms

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Support new turbo module EventEmitter APIs with a new REACT_EVENT_EMITTER macro and matching spec codegen

3 participants