Fabric: UIManager's API for installing and uninstalling itself
Summary: UIManager now can install and uninstall itself calling a functions that are provided as constructor arguments. Reviewed By: mdvacca Differential Revision: D9931329 fbshipit-source-id: b8d2d9925b0e2db0fed44bdf2e185d198fabd5ee
This commit is contained in:
parent
bcdf81918b
commit
4a8613f40f
|
@ -89,6 +89,17 @@ static const std::string componentNameByReactViewName(std::string viewName) {
|
|||
return viewName;
|
||||
}
|
||||
|
||||
FabricUIManager::FabricUIManager(std::function<UIManagerInstaller> installer, std::function<UIManagerUninstaller> uninstaller):
|
||||
installer_(std::move(installer)),
|
||||
uninstaller_(std::move(uninstaller)) {
|
||||
|
||||
installer_(*this);
|
||||
}
|
||||
|
||||
FabricUIManager::~FabricUIManager() {
|
||||
uninstaller_();
|
||||
}
|
||||
|
||||
void FabricUIManager::setComponentDescriptorRegistry(const SharedComponentDescriptorRegistry &componentDescriptorRegistry) {
|
||||
componentDescriptorRegistry_ = componentDescriptorRegistry;
|
||||
}
|
||||
|
|
|
@ -21,12 +21,22 @@ namespace react {
|
|||
class FabricUIManager;
|
||||
using UIManager = FabricUIManager;
|
||||
|
||||
/*
|
||||
* Particular implementations of those functions should capture references to
|
||||
* the runtime and ensure proper threading.
|
||||
*/
|
||||
using UIManagerInstaller = void (UIManager &uiManager);
|
||||
using UIManagerUninstaller = void ();
|
||||
|
||||
using DispatchEventToEmptyTargetFunction = void (const EventHandler &eventHandler, const std::string &type, const folly::dynamic &payload);
|
||||
using DispatchEventToTargetFunction = void (const EventHandler &eventHandler, const EventTarget &eventTarget, const std::string &type, const folly::dynamic &payload);
|
||||
|
||||
class FabricUIManager {
|
||||
public:
|
||||
|
||||
FabricUIManager(std::function<UIManagerInstaller> installer, std::function<UIManagerUninstaller> uninstaller);
|
||||
~FabricUIManager();
|
||||
|
||||
#pragma mark - Native-facing Interface
|
||||
|
||||
void setComponentDescriptorRegistry(const SharedComponentDescriptorRegistry &componentDescriptorRegistry);
|
||||
|
@ -77,6 +87,9 @@ private:
|
|||
mutable UniqueEventHandler eventHandler_;
|
||||
std::function<DispatchEventToEmptyTargetFunction> dispatchEventToEmptyTargetFunction_;
|
||||
std::function<DispatchEventToTargetFunction> dispatchEventToTargetFunction_;
|
||||
|
||||
std::function<UIManagerInstaller> installer_;
|
||||
std::function<UIManagerUninstaller> uninstaller_;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -18,7 +18,10 @@ namespace react {
|
|||
Scheduler::Scheduler(const SharedContextContainer &contextContainer):
|
||||
contextContainer_(contextContainer) {
|
||||
|
||||
uiManager_ = std::make_shared<FabricUIManager>();
|
||||
uiManager_ = std::make_shared<FabricUIManager>(
|
||||
contextContainer->getInstance<std::function<UIManagerInstaller>>("uimanager-installer"),
|
||||
contextContainer->getInstance<std::function<UIManagerUninstaller>>("uimanager-uninstaller")
|
||||
);
|
||||
|
||||
auto eventDispatcher =
|
||||
std::make_shared<EventDispatcher>(
|
||||
|
|
Loading…
Reference in New Issue