Files
Joshua Gross 1592acd4a9 Small changes to State objects to support Android
Summary: Small changes to State objects to support Android. See following diffs.

Reviewed By: mdvacca

Differential Revision: D14663470

fbshipit-source-id: 878f4dc39265991a7b8ff54ca80bdb862f1dd3de
2019-03-29 01:17:19 -07:00

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