Make normalizeEventType public (#45900)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45900

Changelog: [internal]

make `normalizeEventType` public, it looks like a nice util when we want to write code to intercept event, e.g. "scroll" event could be named as "onScroll" or "topScroll", this function contains the source of truth of how RN parses it

Reviewed By: christophpurrer

Differential Revision: D60767388

fbshipit-source-id: b3880fda57e2d92d9d199db5f5d39b8a8435820c
This commit is contained in:
Zeya Peng
2024-08-05 22:12:26 -07:00
committed by Facebook GitHub Bot
parent b0b898b460
commit 67367a0bba
2 changed files with 3 additions and 1 deletions
@@ -26,7 +26,7 @@ static bool hasPrefix(const std::string& str, const std::string& prefix) {
* "top" prefix. E.g. "eventName" becomes "topEventName", "onEventName" also
* becomes "topEventName".
*/
static std::string normalizeEventType(std::string type) {
/* static */ std::string EventEmitter::normalizeEventType(std::string type) {
auto prefixedType = std::move(type);
if (facebook::react::hasPrefix(prefixedType, "top")) {
return prefixedType;
@@ -33,6 +33,8 @@ class EventEmitter {
public:
using Shared = std::shared_ptr<const EventEmitter>;
static std::string normalizeEventType(std::string type);
static std::mutex& DispatchMutex();
static ValueFactory defaultPayloadFactory();