Skip to content

Commit

Permalink
Remove EventHandler type (facebook#40866)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#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
  • Loading branch information
javache authored and facebook-github-bot committed Oct 16, 2023
1 parent f308f02 commit 50522cf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 46 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,14 @@ void UIManagerBinding::dispatchEventToJS(
LOG(WARNING) << "instanceHandle is null, event will be dropped";
}

auto& eventHandlerWrapper =
static_cast<const EventHandlerWrapper&>(*eventHandler_);

currentEventPriority_ = priority;
eventHandlerWrapper.callback.call(
runtime,
{std::move(instanceHandle),
jsi::String::createFromUtf8(runtime, type),
std::move(payload)});
if (eventHandler_) {
eventHandler_->call(
runtime,
std::move(instanceHandle),
jsi::String::createFromUtf8(runtime, type),
std::move(payload));
}
currentEventPriority_ = ReactEventPriority::Default;
}

Expand Down Expand Up @@ -545,7 +544,7 @@ jsi::Value UIManagerBinding::get(
auto eventHandler =
arguments[0].getObject(runtime).getFunction(runtime);
eventHandler_ =
std::make_unique<EventHandlerWrapper>(std::move(eventHandler));
std::make_unique<jsi::Function>(std::move(eventHandler));
return jsi::Value::undefined();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class UIManagerBinding : public jsi::HostObject {
const EventPayload& payload) const;

std::shared_ptr<UIManager> uiManager_;
std::unique_ptr<const EventHandler> eventHandler_;
std::unique_ptr<jsi::Function> eventHandler_;
mutable PointerEventsProcessor pointerEventsProcessor_;
mutable ReactEventPriority currentEventPriority_;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <jsi/jsi.h>
#include <react/debug/react_native_assert.h>
#include <react/renderer/components/text/RawTextShadowNode.h>
#include <react/renderer/core/EventHandler.h>
#include <react/renderer/core/LayoutMetrics.h>
#include <react/renderer/core/ShadowNode.h>
#include <react/renderer/core/TraitCast.h>
Expand All @@ -23,13 +22,6 @@ namespace facebook::react {
using BackgroundExecutor =
std::function<void(std::function<void()>&& callback)>;

struct EventHandlerWrapper : public EventHandler {
EventHandlerWrapper(jsi::Function eventHandler)
: callback(std::move(eventHandler)) {}

jsi::Function callback;
};

struct ShadowNodeListWrapper : public jsi::NativeState {
ShadowNodeListWrapper(ShadowNode::UnsharedListOfShared shadowNodeList)
: shadowNodeList(std::move(shadowNodeList)) {}
Expand Down

0 comments on commit 50522cf

Please sign in to comment.