mirror of
https://github.com/status-im/react-native.git
synced 2025-01-30 11:14:49 +00:00
beb3fcda34
Summary: This is the first attempt to implement some base part of event dispatching pipeline from end-to-end. Even when it is working, all this is still incomplete and generally up in the air. We are still messing proper implementation of event queue, priority, and synchronization of react reconciliation process with event scheduling. Reviewed By: fkgozali Differential Revision: D8212271 fbshipit-source-id: 92f9427d14726441c70ffff294ac95eeb004152a
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "SchedulerEventDispatcher.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
// TODO(T29874519): Get rid of "top" prefix once and for all.
|
|
/*
|
|
* Capitalizes the first letter of the event type and adds "top" prefix
|
|
* (e.g. "layout" becames "topLayout").
|
|
*/
|
|
static std::string normalizeEventType(const std::string &type) {
|
|
std::string prefixedType = type;
|
|
prefixedType[0] = toupper(prefixedType[0]);
|
|
prefixedType.insert(0, "top");
|
|
return prefixedType;
|
|
}
|
|
|
|
void SchedulerEventDispatcher::setUIManager(std::shared_ptr<const FabricUIManager> uiManager) {
|
|
uiManager_ = uiManager;
|
|
}
|
|
|
|
EventTarget SchedulerEventDispatcher::createEventTarget(const InstanceHandle &instanceHandle) const {
|
|
return uiManager_->createEventTarget(instanceHandle);
|
|
}
|
|
|
|
void SchedulerEventDispatcher::releaseEventTarget(const EventTarget &eventTarget) const {
|
|
uiManager_->releaseEventTarget(eventTarget);
|
|
}
|
|
|
|
void SchedulerEventDispatcher::dispatchEvent(
|
|
const EventTarget &eventTarget,
|
|
const std::string &type,
|
|
const folly::dynamic &payload,
|
|
const EventPriority &priority
|
|
) const {
|
|
uiManager_->dispatchEvent(eventTarget, normalizeEventType(type), payload);
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|