Skip to content

feat: Replace EventEmitter with EventTarget in Dimensions - #57432

Open
retyui wants to merge 2 commits into
react:mainfrom
retyui:chore/retyui/Dimensions.addEventListener
Open

retyui wants to merge 2 commits into
react:mainfrom
retyui:chore/retyui/Dimensions.addEventListener

Conversation

@retyui

@retyui retyui commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Motivation: Make addEventListener(...) method - event target like

So, Dimensions.addEventListener now accept 3rd argument with options { once?: boolean, signal?: AbortSignal }

// 1. `once: true` - the listener would be automatically removed when invoked
Dimensions.addEventListener('change', listener, {once: true});

// 2. `signal?: AbortSignal` the listener will be removed when the `abort()` method
const controller = new AbortController();
Dimensions.addEventListener('change', listener, {signal: controller.signal});

Changelog:

[GENERAL] [CHANGED] - Replace EventEmitter with EventTarget in Dimensions

Test Plan:

yarn fantom packages/react-native/Libraries/Utilities/__tests__/Dimensions-itest.js --watch

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 3, 2026
@facebook-github-tools facebook-github-tools Bot added p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jul 3, 2026
@retyui

retyui commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

can't build types (

yarn build-types    


Analysis will use the bundled TypeScript version 5.8.2
/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:338
                                    throw new node_core_library_1.InternalError(`Unable to follow symbol for "${identifierNode.text}"`);
                                          ^

InternalError: Internal Error: Unable to follow symbol for "AbortSignal"

You have encountered a software defect. Please consider reporting the issue to the maintainers of this application.
    at AstSymbolTable._analyzeChildTree (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:338:43)
    at AstSymbolTable._analyzeChildTree (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:387:18)
    ... collapsed 7 duplicate lines matching above 1 lines 7 times...
    at AstSymbolTable._analyzeAstSymbol (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:257:18)
    at /Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:269:34
    at AstDeclaration.forEachDeclarationRecursive (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstDeclaration.js:178:9)
    at AstDeclaration.forEachDeclarationRecursive (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstDeclaration.js:180:19)
    at AstSymbol.forEachDeclarationRecursive (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbol.js:103:28)
    at AstSymbolTable._analyzeAstSymbol (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:264:27)
    at AstSymbolTable.analyze (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:123:25)
    at /Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:263:62
    at Map.forEach (<anonymous>)
    at ExportAnalyzer._collectAllExportsRecursive (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:252:48)
    at ExportAnalyzer.fetchAstModuleExportInfo (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/ExportAnalyzer.js:194:18)
    at AstSymbolTable.fetchAstModuleExportInfo (/Users/RN/node_modules/@microsoft/api-extractor/lib/analyzer/AstSymbolTable.js:99:37)
    at Collector.analyze (/Users/RN/node_modules/@microsoft/api-extractor/lib/collector/Collector.js:224:111)
    at Extractor.invoke (/Users/RN/node_modules/@microsoft/api-extractor/lib/api/Extractor.js:154:19)
    at buildAPISnapshot (/Users/RN/scripts/js-api/build-types/buildApiSnapshot.js:71:37)
    at async main (/Users/RN/scripts/js-api/build-types/index.js:87:5) {
  unformattedMessage: 'Unable to follow symbol for "AbortSignal"'
}

@retyui
retyui force-pushed the chore/retyui/Dimensions.addEventListener branch from a920b5d to a89df86 Compare October 19, 2026 08:33

@rachel11026725 rachel11026725 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please fix

@retyui

retyui commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Please fix

@rachel11026725 I found the way to fix build-types cmd, can you review it again ?

@retyui
retyui requested a review from rachel11026725 October 19, 2026 08:50
@github-actions

Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants