Skip to content

Appearance: Dedupe colorScheme Validation Logic#46120

Closed
yungsters wants to merge 3 commits into
facebook:mainfrom
yungsters:export-D61567881
Closed

Appearance: Dedupe colorScheme Validation Logic#46120
yungsters wants to merge 3 commits into
facebook:mainfrom
yungsters:export-D61567881

Conversation

@yungsters
Copy link
Copy Markdown
Contributor

Summary:
Currently, the implementation of Appearance duplicates the validation logic of string colorScheme values multiple times.

This leads to more complicated code and also unnecessary work in certain edge cases (e.g. when NativeAppearance is not registered).

This refactors Appearance to be simpler and to do less work. I've also configured NativeAppearance.setColorScheme to be non-nullable because it has existed since 2023.

Changelog:
[Internal]

Reviewed By: TheSavior

Differential Revision: D61567881

Summary:
Straightforward migration of the `Appearance` module to use ESM named exports.

Changelog:
[Internal]

Reviewed By: TheSavior

Differential Revision: D61567882
Summary:
Updates `Appearance` on Android to supply the native module to `NativeEventEmitter` so that the native listener count can be managed like it is on iOS.

This was previously required by macOS and iOS. Android and Windows also already implement:

```
interface NativeModule {
  addListener(eventType: string): void;
  removeListeners(count: number): void;
}
```

So we should start passing `NativeAppearance` into the `NativeEventEmitter` constructor across all platforms.

Changelog:
[Internal]

Reviewed By: TheSavior

Differential Revision: D61567883
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Aug 20, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D61567881

Summary:
Pull Request resolved: facebook#46120

Currently, the implementation of `Appearance` duplicates the validation logic of string `colorScheme` values multiple times.

This leads to more complicated code and also unnecessary work in certain edge cases (e.g. when `NativeAppearance` is not registered).

This refactors `Appearance` to be simpler and to do less work. I've also configured `NativeAppearance.setColorScheme` to be non-nullable because it has existed since 2023.

Changelog:
[Internal]

Reviewed By: TheSavior

Differential Revision: D61567881
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D61567881

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 21, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in ed3ca07.

@yungsters yungsters deleted the export-D61567881 branch March 13, 2025 16:10
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. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants