Skip to content

Commit

Permalink
remove redundant method from MountItemDispatcher (#41061)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #41061

changelog: [internal]

Method `dispatchCommandMountItem` only calls `addViewCommandMountItem`  without adding anything on top of it. The name is inaccurate because it doesn't dispatch mount item, it queues it.

Let's remove one of them to simplify the API.

Reviewed By: javache

Differential Revision: D50408576

fbshipit-source-id: 3a4871c38e7b081a5e27aba211d61254075e76cd
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 19, 2023
1 parent c9d3289 commit 4134d8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ public void dispatchCommand(
final int reactTag,
final int commandId,
@Nullable final ReadableArray commandArgs) {
mMountItemDispatcher.dispatchCommandMountItem(
mMountItemDispatcher.addViewCommandMountItem(
MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandId, commandArgs));
}
Expand All @@ -1039,10 +1039,10 @@ public void dispatchCommand(
// For Fabric Interop, we check if the commandId is an integer. If it is, we use the integer
// overload of dispatchCommand. Otherwise, we use the string overload.
// and the events won't be correctly dispatched.
mMountItemDispatcher.dispatchCommandMountItem(
mMountItemDispatcher.addViewCommandMountItem(
createDispatchCommandMountItemForInterop(surfaceId, reactTag, commandId, commandArgs));
} else {
mMountItemDispatcher.dispatchCommandMountItem(
mMountItemDispatcher.addViewCommandMountItem(
MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandId, commandArgs));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

package com.facebook.react.fabric.mounting;

import static com.facebook.infer.annotation.ThreadConfined.ANY;
import static com.facebook.infer.annotation.ThreadConfined.UI;
import static com.facebook.react.fabric.FabricUIManager.ENABLE_FABRIC_LOGS;
import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT;

import android.os.SystemClock;
import android.view.View;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
Expand Down Expand Up @@ -62,10 +60,8 @@ public MountItemDispatcher(MountingManager mountingManager, ItemDispatchListener
mItemDispatchListener = listener;
}

@AnyThread
@ThreadConfined(ANY)
public void dispatchCommandMountItem(DispatchCommandMountItem command) {
addViewCommandMountItem(command);
public void addViewCommandMountItem(DispatchCommandMountItem mountItem) {
mViewCommandMountItems.add(mountItem);
}

public void addMountItem(MountItem mountItem) {
Expand All @@ -88,10 +84,6 @@ public void addPreAllocateMountItem(MountItem mountItem) {
}
}

public void addViewCommandMountItem(DispatchCommandMountItem mountItem) {
mViewCommandMountItems.add(mountItem);
}

/**
* Try to dispatch MountItems. In case of the exception, we will retry 10 times before giving up.
*/
Expand Down Expand Up @@ -159,7 +151,7 @@ public void dispatchMountItems(Queue<MountItem> mountItems) {
mountItem.incrementRetries();
// In case we haven't retried executing this item yet, execute in the next batch of
// items
dispatchCommandMountItem(mountItem);
addViewCommandMountItem(mountItem);
}
} else {
printMountItem(
Expand Down Expand Up @@ -214,7 +206,7 @@ private boolean dispatchMountItems() {
// the current batch of mount items has finished executing.
if (command.getRetries() == 0) {
command.incrementRetries();
dispatchCommandMountItem(command);
addViewCommandMountItem(command);
} else {
// It's very common for commands to be executed on views that no longer exist - for
// example, a blur event on TextInput being fired because of a navigation event away
Expand Down

0 comments on commit 4134d8d

Please sign in to comment.