Skip to content

Commit

Permalink
introduce CallInvokerHolder stable API
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Android][Added]

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after facebook#43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

this will be forward compatible in the old architecture

Reviewed By: RSNara

Differential Revision: D56866817
  • Loading branch information
philIip authored and facebook-github-bot committed May 3, 2024
1 parent 42a1f51 commit f206616
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public interface CatalystInstance
* Returns a hybrid object that contains a pointer to a JS CallInvoker, which is used to schedule
* work on the JS Thread. Required for TurboModuleManager initialization.
*/
@Deprecated
CallInvokerHolder getJSCallInvokerHolder();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.concurrent.CopyOnWriteArraySet;
Expand Down Expand Up @@ -581,6 +582,14 @@ public boolean isBridgeless() {
return null;
}

/**
* Returns a hybrid object that contains a pointer to a JS CallInvoker, which is used to schedule
* work on the JS Thread.
*/
public @Nullable CallInvokerHolder getJSCallInvokerHolder() {
return mCatalystInstance.getJSCallInvokerHolder();
}

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.EventDispatcherProvider;
import java.lang.reflect.InvocationHandler;
Expand Down Expand Up @@ -169,6 +170,11 @@ public void handleException(Exception e) {
mReactHost.handleHostException(e);
}

@Override
public @Nullable CallInvokerHolder getJSCallInvokerHolder() {
return mReactHost.getJSCallInvokerHolder();
}

DefaultHardwareBackBtnHandler getDefaultHardwareBackBtnHandler() {
return mReactHost.getDefaultBackButtonHandler();
}
Expand Down

0 comments on commit f206616

Please sign in to comment.