2018-04-10 19:46:20 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <fabric/core/ComponentDescriptor.h>
|
|
|
|
#include <fabric/core/LayoutConstraints.h>
|
|
|
|
#include <fabric/uimanager/SchedulerDelegate.h>
|
|
|
|
#include <fabric/uimanager/UIManagerDelegate.h>
|
|
|
|
#include <fabric/view/ViewShadowNode.h>
|
2018-05-09 05:56:14 +00:00
|
|
|
#include <fabric/view/RootShadowNode.h>
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
namespace facebook {
|
|
|
|
namespace react {
|
|
|
|
|
|
|
|
class FabricUIManager;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scheduler coordinates Shadow Tree updates and event flows.
|
|
|
|
*/
|
|
|
|
class Scheduler:
|
|
|
|
public UIManagerDelegate {
|
|
|
|
|
|
|
|
public:
|
|
|
|
Scheduler();
|
2018-04-20 16:40:06 +00:00
|
|
|
virtual ~Scheduler();
|
2018-04-10 19:46:20 +00:00
|
|
|
|
|
|
|
#pragma mark - Root Nodes Managerment
|
|
|
|
|
|
|
|
void registerRootTag(Tag rootTag);
|
|
|
|
void unregisterRootTag(Tag rootTag);
|
|
|
|
|
|
|
|
void setLayoutConstraints(Tag rootTag, LayoutConstraints layoutConstraints);
|
|
|
|
|
|
|
|
#pragma mark - Delegate
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sets and gets the Scheduler's delegate.
|
|
|
|
* The delegate is stored as a raw pointer, so the owner must null
|
|
|
|
* the pointer before being destroyed.
|
|
|
|
*/
|
|
|
|
void setDelegate(SchedulerDelegate *delegate);
|
|
|
|
SchedulerDelegate *getDelegate();
|
|
|
|
|
|
|
|
#pragma mark - UIManagerDelegate
|
|
|
|
|
|
|
|
void uiManagerDidFinishTransaction(Tag rootTag, const SharedShadowNodeUnsharedList &rootChildNodes) override;
|
|
|
|
void uiManagerDidCreateShadowNode(const SharedShadowNode &shadowNode) override;
|
|
|
|
|
|
|
|
#pragma mark - Deprecated
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UIManager instance must be temporarily exposed for registration purposes.
|
|
|
|
*/
|
|
|
|
std::shared_ptr<FabricUIManager> getUIManager_DO_NOT_USE();
|
|
|
|
|
|
|
|
private:
|
|
|
|
SchedulerDelegate *delegate_;
|
|
|
|
std::shared_ptr<FabricUIManager> uiManager_;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All commited `RootShadowNode` instances to differentiate against.
|
|
|
|
*/
|
|
|
|
std::unordered_map<Tag, SharedRootShadowNode> rootNodeRegistry_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace react
|
|
|
|
} // namespace facebook
|