Skip to content

Commit 50522cf

Browse files
javachefacebook-github-bot
authored andcommitted
Remove EventHandler type (#40866)
Summary: Pull Request resolved: #40866 This type doesn't do anything, and we can replace it with a `jsi::Function` inside `UIManagerBinding`. Changelog: [Internal] Reviewed By: rubennorte Differential Revision: D50176084 fbshipit-source-id: 1c782f3e4d212f1d956451fd650d3ed5ed8f0d71
1 parent f308f02 commit 50522cf

File tree

4 files changed

+9
-46
lines changed

4 files changed

+9
-46
lines changed

packages/react-native/ReactCommon/react/renderer/core/EventHandler.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,14 @@ void UIManagerBinding::dispatchEventToJS(
155155
LOG(WARNING) << "instanceHandle is null, event will be dropped";
156156
}
157157

158-
auto& eventHandlerWrapper =
159-
static_cast<const EventHandlerWrapper&>(*eventHandler_);
160-
161158
currentEventPriority_ = priority;
162-
eventHandlerWrapper.callback.call(
163-
runtime,
164-
{std::move(instanceHandle),
165-
jsi::String::createFromUtf8(runtime, type),
166-
std::move(payload)});
159+
if (eventHandler_) {
160+
eventHandler_->call(
161+
runtime,
162+
std::move(instanceHandle),
163+
jsi::String::createFromUtf8(runtime, type),
164+
std::move(payload));
165+
}
167166
currentEventPriority_ = ReactEventPriority::Default;
168167
}
169168

@@ -545,7 +544,7 @@ jsi::Value UIManagerBinding::get(
545544
auto eventHandler =
546545
arguments[0].getObject(runtime).getFunction(runtime);
547546
eventHandler_ =
548-
std::make_unique<EventHandlerWrapper>(std::move(eventHandler));
547+
std::make_unique<jsi::Function>(std::move(eventHandler));
549548
return jsi::Value::undefined();
550549
});
551550
}

packages/react-native/ReactCommon/react/renderer/uimanager/UIManagerBinding.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class UIManagerBinding : public jsi::HostObject {
8484
const EventPayload& payload) const;
8585

8686
std::shared_ptr<UIManager> uiManager_;
87-
std::unique_ptr<const EventHandler> eventHandler_;
87+
std::unique_ptr<jsi::Function> eventHandler_;
8888
mutable PointerEventsProcessor pointerEventsProcessor_;
8989
mutable ReactEventPriority currentEventPriority_;
9090
};

packages/react-native/ReactCommon/react/renderer/uimanager/primitives.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <jsi/jsi.h>
1313
#include <react/debug/react_native_assert.h>
1414
#include <react/renderer/components/text/RawTextShadowNode.h>
15-
#include <react/renderer/core/EventHandler.h>
1615
#include <react/renderer/core/LayoutMetrics.h>
1716
#include <react/renderer/core/ShadowNode.h>
1817
#include <react/renderer/core/TraitCast.h>
@@ -23,13 +22,6 @@ namespace facebook::react {
2322
using BackgroundExecutor =
2423
std::function<void(std::function<void()>&& callback)>;
2524

26-
struct EventHandlerWrapper : public EventHandler {
27-
EventHandlerWrapper(jsi::Function eventHandler)
28-
: callback(std::move(eventHandler)) {}
29-
30-
jsi::Function callback;
31-
};
32-
3325
struct ShadowNodeListWrapper : public jsi::NativeState {
3426
ShadowNodeListWrapper(ShadowNode::UnsharedListOfShared shadowNodeList)
3527
: shadowNodeList(std::move(shadowNodeList)) {}

0 commit comments

Comments
 (0)