Fabric: Shipping updateStateWithAutorepeat as the only way to update a state

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
This commit is contained in:
Valentin Shergin
2020-12-23 21:49:44 -08:00
committed by Facebook GitHub Bot
parent 3ade096f02
commit f379b1e583
12 changed files with 25 additions and 170 deletions
@@ -79,10 +79,9 @@ public class FabricViewStateManager {
if (stateUpdate == null) {
return;
}
stateWrapper.updateState(
stateUpdate,
// Failure callback - this is run if the updateState call fails
failureRunnable);
// TODO: State update cannot fail; remove `failureRunnable` and custom retrying logic.
stateWrapper.updateState(stateUpdate);
}
public void setState(final StateUpdateCallback stateUpdateCallback) {