mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
a8b090b128
Summary: This is *another* attempt to solve a failed state update problem. Unfortunately, some applications are inherently not compatible with the "let's recommit the update on the application side in case it failed" approach. The problem is that if we call `updateState` on the application side, we miss the original event window. E.g. if we need to deliver some state update with AsyncBatched priority and if the update fails, we lose the opportunity to commit it on time. These issues can be critical for some complex use-cases as ComponentKit interop. This diff adds implementation for `updateState` that does the work a bit differently. For all failed state updates it tres to recommit them asap using `ShadowTree::commit` and calling lambda on every attempt. With this approach the update might fail in two cases: The node disappeared from the tree, so there is no way to update it. The lambda returned `nullptr` indicating that the update is no longer needed. We need this for the ComponentKit interoperability layer that is very sensitive for missing state updates. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D23603958 fbshipit-source-id: a3b8c09fb2f1c8302583aa5880b48fc0840224e3
34 lines
733 B
C++
34 lines
733 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;
|
|
bool autorepeat;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|