Fabric: `ConcreteShadowNode::initialStateData()` now accepts a `ShadowNodeFamilyFragment` instead of just a `SurfaceId`
Summary: We need it to be able pass an `EventEmitter` object to constructed concrete State objects. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D21169581 fbshipit-source-id: 3eef0310de7e2f061108aa85c1a39678a43fe85e
This commit is contained in:
Родитель
df03228a61
Коммит
3246eaec44
|
@ -43,7 +43,7 @@ class ImageShadowNode final : public ConcreteViewShadowNode<
|
|||
|
||||
static ImageState initialStateData(
|
||||
ShadowNodeFragment const &fragment,
|
||||
SurfaceId const surfaceId,
|
||||
ShadowNodeFamilyFragment const &familyFragment,
|
||||
ComponentDescriptor const &componentDescriptor) {
|
||||
auto imageSource = ImageSource{ImageSource::Type::Invalid};
|
||||
return {imageSource, {imageSource, nullptr}};
|
||||
|
|
|
@ -40,7 +40,7 @@ class SliderShadowNode final : public ConcreteViewShadowNode<
|
|||
|
||||
static SliderState initialStateData(
|
||||
ShadowNodeFragment const &fragment,
|
||||
SurfaceId const surfaceId,
|
||||
ShadowNodeFamilyFragment const &familyFragment,
|
||||
ComponentDescriptor const &componentDescriptor) {
|
||||
auto imageSource = ImageSource{ImageSource::Type::Invalid};
|
||||
return {imageSource,
|
||||
|
|
|
@ -133,7 +133,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
return std::make_shared<ConcreteState>(
|
||||
std::make_shared<ConcreteStateData const>(
|
||||
ConcreteShadowNode::initialStateData(
|
||||
fragment, family->getSurfaceId(), *this)),
|
||||
fragment, ShadowNodeFamilyFragment::build(*family), *this)),
|
||||
family);
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class ConcreteShadowNode : public BaseShadowNodeT {
|
|||
|
||||
static ConcreteStateData initialStateData(
|
||||
ShadowNodeFragment const &fragment,
|
||||
SurfaceId const surfaceId,
|
||||
ShadowNodeFamilyFragment const &familyFragment,
|
||||
ComponentDescriptor const &componentDescriptor) {
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ class ShadowNodeFamily {
|
|||
|
||||
private:
|
||||
friend ShadowNode;
|
||||
friend ShadowNodeFamilyFragment;
|
||||
|
||||
EventDispatcher::Weak eventDispatcher_;
|
||||
mutable std::shared_ptr<State const> mostRecentState_;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "ShadowNodeFamilyFragment.h"
|
||||
|
||||
#include <react/core/ShadowNodeFamily.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
ShadowNodeFamilyFragment ShadowNodeFamilyFragment::build(
|
||||
ShadowNodeFamily const &family) {
|
||||
return {
|
||||
family.tag_,
|
||||
family.surfaceId_,
|
||||
family.eventEmitter_,
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
|
@ -13,6 +13,8 @@
|
|||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class ShadowNodeFamily;
|
||||
|
||||
/*
|
||||
* Note: All of the fields are `const &` references (essentially just raw
|
||||
* pointers) which means that the Fragment does not copy/store them nor
|
||||
|
@ -20,6 +22,8 @@ namespace react {
|
|||
*/
|
||||
class ShadowNodeFamilyFragment final {
|
||||
public:
|
||||
static ShadowNodeFamilyFragment build(ShadowNodeFamily const &family);
|
||||
|
||||
Tag const tag;
|
||||
SurfaceId const surfaceId;
|
||||
EventEmitter::Shared const &eventEmitter;
|
||||
|
|
Загрузка…
Ссылка в новой задаче