mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Introduce new Fabric API setSurfaceProps
Summary: This diff introduces a new fabric API called setSurfaceProps that will be used to call the new JS api "setSurfaceProps" changelog: [internal] internal Reviewed By: sammy-SC Differential Revision: D27607588 fbshipit-source-id: 36a19f728af244d7e72687d9305b1c568e2b8ec6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b5e2e1d52d
commit
680dd36fd1
@@ -164,6 +164,22 @@ void UIManager::startSurface(
|
||||
});
|
||||
}
|
||||
|
||||
void UIManager::setSurfaceProps(
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const {
|
||||
SystraceSection s("UIManager::setSurfaceProps");
|
||||
|
||||
runtimeExecutor_([=](jsi::Runtime &runtime) {
|
||||
auto uiManagerBinding = UIManagerBinding::getBinding(runtime);
|
||||
if (!uiManagerBinding) {
|
||||
return;
|
||||
}
|
||||
|
||||
uiManagerBinding->setSurfaceProps(runtime, surfaceId, moduleName, props);
|
||||
});
|
||||
}
|
||||
|
||||
ShadowTree::Unique UIManager::stopSurface(SurfaceId surfaceId) const {
|
||||
SystraceSection s("UIManager::stopSurface");
|
||||
|
||||
|
||||
@@ -89,6 +89,11 @@ class UIManager final : public ShadowTreeDelegate {
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const;
|
||||
|
||||
void setSurfaceProps(
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const;
|
||||
|
||||
ShadowTree::Unique stopSurface(SurfaceId surfaceId) const;
|
||||
|
||||
#pragma mark - ShadowTreeDelegate
|
||||
|
||||
@@ -169,6 +169,36 @@ void UIManagerBinding::startSurface(
|
||||
}
|
||||
}
|
||||
|
||||
void UIManagerBinding::setSurfaceProps(
|
||||
jsi::Runtime &runtime,
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &initalProps) const {
|
||||
folly::dynamic parameters = folly::dynamic::object();
|
||||
parameters["rootTag"] = surfaceId;
|
||||
parameters["initialProps"] = initalProps;
|
||||
parameters["fabric"] = true;
|
||||
|
||||
if (moduleName.compare("LogBox") != 0 &&
|
||||
runtime.global().hasProperty(runtime, "RN$SurfaceRegistry")) {
|
||||
auto registry =
|
||||
runtime.global().getPropertyAsObject(runtime, "RN$SurfaceRegistry");
|
||||
auto method = registry.getPropertyAsFunction(runtime, "setSurfaceProps");
|
||||
|
||||
method.call(
|
||||
runtime,
|
||||
{jsi::String::createFromUtf8(runtime, moduleName),
|
||||
jsi::valueFromDynamic(runtime, parameters)});
|
||||
} else {
|
||||
callMethodOfModule(
|
||||
runtime,
|
||||
"AppRegistry",
|
||||
"setSurfaceProps",
|
||||
{jsi::String::createFromUtf8(runtime, moduleName),
|
||||
jsi::valueFromDynamic(runtime, parameters)});
|
||||
}
|
||||
}
|
||||
|
||||
void UIManagerBinding::stopSurface(jsi::Runtime &runtime, SurfaceId surfaceId)
|
||||
const {
|
||||
auto global = runtime.global();
|
||||
|
||||
@@ -55,6 +55,17 @@ class UIManagerBinding : public jsi::HostObject {
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &initalProps) const;
|
||||
|
||||
/*
|
||||
* Updates the React Native Surface identified with surfaceId and moduleName
|
||||
* with the given props.
|
||||
* Thread synchronization must be enforced externally.
|
||||
*/
|
||||
void setSurfaceProps(
|
||||
jsi::Runtime &runtime,
|
||||
SurfaceId surfaceId,
|
||||
std::string const &moduleName,
|
||||
folly::dynamic const &props) const;
|
||||
|
||||
/*
|
||||
* Stops React Native Surface with given id.
|
||||
* Thread synchronization must be enforced externally.
|
||||
|
||||
Reference in New Issue
Block a user