Files
react-native/React/Fabric/Mounting/RCTComponentViewDescriptor.h
T
Valentin Shergin 41cf6da074 Fabric: Implementation of RCTMountingTransactionObserving protocol
Summary:
This diff finally uses all facilities from the previous diffs to build an implementation of  `RCTMountingTransactionObserving` protocol which does *not* require using expensive Objective-C runtime features.

In the coming diffs, we will see how it can/should be used.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18217101

fbshipit-source-id: 34f411dcb527dc81570c2f2833ce13b40e1450db
2019-11-01 09:38:25 -07:00

53 lines
1.4 KiB
Objective-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.
*/
#import <UIKit/UIKit.h>
#import <React/RCTComponentViewProtocol.h>
NS_ASSUME_NONNULL_BEGIN
/*
* Holds a native view instance and a set of attributes associated with it.
* Mounting infrastructure uses these objects to bookkeep views and cache their
* attributes for efficient access.
*/
class RCTComponentViewDescriptor final {
public:
/*
* Associated (and owned) native view instance.
*/
UIView<RCTComponentViewProtocol> *view;
/*
* Indicates a requirement to call on the view methods from
* `RCTMountingTransactionObserving` protocol.
*/
bool observesMountingTransactionWillMount{false};
bool observesMountingTransactionDidMount{false};
};
inline bool operator==(RCTComponentViewDescriptor const &lhs, RCTComponentViewDescriptor const &rhs)
{
return lhs.view == rhs.view;
}
inline bool operator!=(RCTComponentViewDescriptor const &lhs, RCTComponentViewDescriptor const &rhs)
{
return lhs.view != rhs.view;
}
template <>
struct std::hash<RCTComponentViewDescriptor> {
size_t operator()(RCTComponentViewDescriptor const &componentViewDescriptor) const
{
return std::hash<void *>()((__bridge void *)componentViewDescriptor.view);
}
};
NS_ASSUME_NONNULL_END