Switch to using safer UpdateState mechanism

Summary:
Update FabricViewStateManager so that the caller can bail out of updates by returning null.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22966024

fbshipit-source-id: 31cd9ec8a9a9918fbb94844e30ed1a2fcc61997d
This commit is contained in:
Joshua Gross
2020-08-05 21:59:12 -07:00
committed by Facebook GitHub Bot
parent d0e710bfb3
commit 0713246e7b
3 changed files with 5 additions and 10 deletions
@@ -47,12 +47,6 @@ public class StateWrapperImpl implements StateWrapper {
public native void updateStateWithFailureCallbackImpl(
@NonNull NativeMap map, Object self, int updateStateId);
@Override
public void updateState(@NonNull WritableMap map) {
mUpdateStateId++;
updateStateImpl((NativeMap) map);
}
@Override
public void updateState(@NonNull WritableMap map, Runnable failureCallback) {
mUpdateStateId++;
@@ -78,8 +78,12 @@ public class FabricViewStateManager {
}
};
}
@Nullable WritableMap stateUpdate = stateUpdateCallback.getStateUpdate();
if (stateUpdate == null) {
return;
}
stateWrapper.updateState(
stateUpdateCallback.getStateUpdate(),
stateUpdate,
// Failure callback - this is run if the updateState call fails
failureRunnable);
}
@@ -21,9 +21,6 @@ public interface StateWrapper {
*/
ReadableNativeMap getState();
/** Pass a map of values back to the C++ layer. */
void updateState(WritableMap map);
/**
* Pass a map of values back to the C++ layer. /Last/ runnable passed into updateState is called
* if an updateState call fails.