Files
react-native/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h
T
Valentin Shergin 03443d77f5 Fabic: Opening up fields of ShadowNodeFamilyFragment::Value and ShadowNodeFragment::Value
Summary:
There is no good reason why they are `const` and `private`, in the future diffs we will need to mutate them.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D21992197

fbshipit-source-id: f8aee8db9ea1ff8282b38fbe3a966911678ee2c4
2020-06-11 09:48:38 -07:00

67 lines
1.9 KiB
C++

/*
* 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.
*/
#pragma once
#include <react/core/EventEmitter.h>
#include <react/core/Props.h>
#include <react/core/ReactPrimitives.h>
#include <react/core/ShadowNode.h>
#include <react/core/State.h>
namespace facebook {
namespace react {
/*
* An object which supposed to be used as a parameter specifying a shape
* of created or cloned ShadowNode.
* Note: Most of the fields are `const &` references (essentially just raw
* pointers) which means that the Fragment does not copy/store them nor
* retain ownership of them.
* Use `ShadowNodeFragment::Value` (see below) to create an owning copy of the
* fragment content to store or pass the data asynchronously.
*/
struct ShadowNodeFragment {
Props::Shared const &props = propsPlaceholder();
ShadowNode::SharedListOfShared const &children = childrenPlaceholder();
State::Shared const &state = statePlaceholder();
/*
* Placeholders.
* Use as default arguments as an indication that the field does not need to
* be changed.
*/
static Props::Shared const &propsPlaceholder();
static ShadowNode::SharedListOfShared const &childrenPlaceholder();
static State::Shared const &statePlaceholder();
/*
* `ShadowNodeFragment` is not owning data-structure, it only stores raw
* pointers to the data. `ShadowNodeFragment::Value` is a convenient owning
* counterpart of that.
*/
class Value final {
public:
/*
* Creates an object with given `ShadowNodeFragment`.
*/
Value(ShadowNodeFragment const &fragment);
/*
* Creates a `ShadowNodeFragment` from the object.
*/
explicit operator ShadowNodeFragment() const;
Props::Shared props;
ShadowNode::SharedListOfShared children;
State::Shared state;
};
};
} // namespace react
} // namespace facebook