mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-15 12:57:38 +08:00
Summary: Small changes to State objects to support Android. See following diffs. Reviewed By: mdvacca Differential Revision: D14663470 fbshipit-source-id: 878f4dc39265991a7b8ff54ca80bdb862f1dd3de
55 lines
1.2 KiB
C++
55 lines
1.2 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 <folly/dynamic.h>
|
|
#include <react/core/StateCoordinator.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
class ShadowNode;
|
|
|
|
/*
|
|
* An abstract interface of State.
|
|
* State is used to control and continuously advance a single vision of some
|
|
* state (arbitrary data) associated with a family of shadow nodes.
|
|
*/
|
|
class State {
|
|
public:
|
|
using Shared = std::shared_ptr<const State>;
|
|
|
|
State(StateCoordinator::Shared stateCoordinator);
|
|
virtual ~State() = default;
|
|
|
|
#ifdef ANDROID
|
|
virtual const folly::dynamic getDynamic() const;
|
|
virtual void updateState(folly::dynamic data) const;
|
|
#endif
|
|
|
|
protected:
|
|
StateCoordinator::Shared stateCoordinator_;
|
|
|
|
private:
|
|
friend class ShadowNode;
|
|
friend class StateCoordinator;
|
|
|
|
/*
|
|
* Must be used by `ShadowNode` *only*.
|
|
*/
|
|
void commit(const ShadowNode &shadowNode) const;
|
|
|
|
/*
|
|
* Must be used by `ShadowNode` *only*.
|
|
*/
|
|
const State::Shared &getCommitedState() const;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|