Files
react-native/ReactCommon/react/renderer/core/StateUpdate.h
T
Joshua Gross 774dec1e17 Introduce general API for setting C++ State from the View layer and getting a notification if it fails, with Android impl
Summary:
iOS will need to be implemented separately, but the shared C++ bits are in place.

Explanation: there is currently no way for the View layer to /know/ if an UpdateState call has succeeded or failed. Generally we just assume it succeeds, but if it fails we have no way of knowing or retrying.

This can cause some UI bugs. To mitigate this, I'm introducing a "failure" notification callback mechanism. The JNI bridging for this is a little complicated to avoid passing Runnable across the JNI, but it
should be much simpler on iOS.

In development this seems to make View components much more reliable.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22940187

fbshipit-source-id: 917f2932ae22d421f91fe8f4fca3f07dc089f820
2020-08-05 06:35:41 -07:00

33 lines
714 B
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 <functional>
#include <react/renderer/core/StateData.h>
namespace facebook {
namespace react {
class ShadowNodeFamily;
using SharedShadowNodeFamily = std::shared_ptr<ShadowNodeFamily const>;
class StateUpdate {
public:
using Callback =
std::function<StateData::Shared(StateData::Shared const &data)>;
using FailureCallback = std::function<void()>;
SharedShadowNodeFamily family;
Callback callback;
FailureCallback failureCallback;
};
} // namespace react
} // namespace facebook