mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
f379b1e583
Summary: This replaces the internal core implementation of `setState` with the new `updateStateWithAutorepeat` which is now the only option. In short, `updateStateWithAutorepeat` works as `setState` with the following features: * The state update might be performed several times until it succeeds. * The callback is being called on every retry with actual previous data provided (can be different on every call). * In case of a static value is provided (simple case, not lambda, the only case on Android for now), the same *new*/provided value will be used for all state updates. In this case, the state update cannot fail. * If a callback is provided, the update operation can be canceled via returning `nullptr` from the callback. This diff removes all mentions of the previous state update approach from the core; some other leftovers will be removed separatly. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25695600 fbshipit-source-id: 14b3d4bad7ee69e024a9b0b9fc018f7d58bf060c
30 lines
938 B
Java
30 lines
938 B
Java
/*
|
|
* 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.
|
|
*/
|
|
|
|
package com.facebook.react.uimanager;
|
|
|
|
import com.facebook.react.bridge.ReadableNativeMap;
|
|
import com.facebook.react.bridge.WritableMap;
|
|
|
|
/**
|
|
* This is a wrapper that can be used for passing State objects from Fabric C++ core to
|
|
* platform-specific components in Java. State allows you to break out of uni-directional dataflow
|
|
* by calling updateState, which communicates state back to the C++ layer.
|
|
*/
|
|
public interface StateWrapper {
|
|
/**
|
|
* Get a ReadableNativeMap object from the C++ layer, which is a K/V map of string keys to values.
|
|
*/
|
|
ReadableNativeMap getState();
|
|
|
|
/**
|
|
* Pass a map of values back to the C++ layer. The operation is performed synchronously and cannot
|
|
* fail.
|
|
*/
|
|
void updateState(WritableMap map);
|
|
}
|