Skip to content

UIManager::add/RemoveEventListener #50453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ void Scheduler::uiManagerShouldSynchronouslyUpdateViewOnUIThread(
}
}

void Scheduler::uiManagerShouldAddEventListener(
std::shared_ptr<const EventListener> listener) {
addEventListener(listener);
}

void Scheduler::uiManagerShouldRemoveEventListener(
const std::shared_ptr<const EventListener>& listener) {
removeEventListener(listener);
}

void Scheduler::reportMount(SurfaceId surfaceId) const {
uiManager_->reportMount(surfaceId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ class Scheduler final : public UIManagerDelegate {
void uiManagerShouldSynchronouslyUpdateViewOnUIThread(
Tag tag,
const folly::dynamic& props) override;
void uiManagerShouldAddEventListener(
std::shared_ptr<const EventListener> listener) final;
void uiManagerShouldRemoveEventListener(
const std::shared_ptr<const EventListener>& listener) final;

#pragma mark - ContextContainer
ContextContainer::Shared getContextContainer() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,4 +681,20 @@ void UIManager::synchronouslyUpdateViewOnUIThread(
}
}

#pragma mark - Add & Remove event listener

void UIManager::addEventListener(
std::shared_ptr<const EventListener> listener) {
if (delegate_ != nullptr) {
delegate_->uiManagerShouldAddEventListener(listener);
}
}

void UIManager::removeEventListener(
const std::shared_ptr<const EventListener>& listener) {
if (delegate_ != nullptr) {
delegate_->uiManagerShouldRemoveEventListener(listener);
}
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ class UIManager final : public ShadowTreeDelegate {
void updateShadowTree(
const std::unordered_map<Tag, folly::dynamic>& tagToProps);

#pragma mark - Add & Remove event listener

void addEventListener(std::shared_ptr<const EventListener> listener);

void removeEventListener(
const std::shared_ptr<const EventListener>& listener);

private:
friend class UIManagerBinding;
friend class Scheduler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,18 @@ class UIManagerDelegate {
Tag tag,
const folly::dynamic& props) = 0;

/*
* Add event listener.
*/
virtual void uiManagerShouldAddEventListener(
std::shared_ptr<const EventListener> listener) = 0;

/*
* Remove event listener.
*/
virtual void uiManagerShouldRemoveEventListener(
const std::shared_ptr<const EventListener>& listener) = 0;

virtual ~UIManagerDelegate() noexcept = default;
};

Expand Down
Loading