Skip to content

Commit

Permalink
Adding FabricUIManager() getter & setter and setter for TurboModuleRe…
Browse files Browse the repository at this point in the history
…gistry (#41302)

Summary:
Pull Request resolved: #41302

Adding  `setTurboModuleRegistry(TurboModuleRegistry turboModuleRegistry)`, `setFabricUIManager(UIManager fabricUIManager)`, `getFabricUIManager()` new APIs

Changelog:
[General][Added] Introduce APIs for FabricUIManager

Reviewed By: philIip

Differential Revision: D50832557

fbshipit-source-id: 9a27a5683f312fb93f09bb4d97a615988269876e
  • Loading branch information
arushikesarwani94 authored and facebook-github-bot committed Nov 8, 2023
1 parent 3e15821 commit 16fb64a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import androidx.annotation.Nullable;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.internal.turbomodule.core.interfaces.CallInvokerHolder;
import com.facebook.react.internal.turbomodule.core.interfaces.NativeMethodCallInvokerHolder;
import com.facebook.react.internal.turbomodule.core.interfaces.TurboModuleRegistry;
import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -134,4 +136,19 @@ public interface CatalystInstance
* hasNativeModule, and getNativeModules can also return TurboModules.
*/
void setTurboModuleManager(JSIModule getter);

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
void setTurboModuleRegistry(TurboModuleRegistry turboModuleRegistry);

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
void setFabricUIManager(UIManager fabricUIManager);

@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.")
UIManager getFabricUIManager();
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public String toString() {
private @Nullable String mSourceURL;

private JavaScriptContextHolder mJavaScriptContextHolder;
private volatile @Nullable TurboModuleRegistry mTurboModuleRegistry = null;
private @Nullable TurboModuleRegistry mTurboModuleRegistry;
private @Nullable UIManager mFabricUIManager;

// C++ parts
private final HybridData mHybridData;
Expand Down Expand Up @@ -351,6 +352,9 @@ public void destroy() {
() -> {
mNativeModuleRegistry.notifyJSInstanceDestroy();
mJSIModuleRegistry.notifyJSInstanceDestroy();
if (mFabricUIManager != null) {
mFabricUIManager.invalidate();
}
boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0);
if (!mBridgeIdleListeners.isEmpty()) {
for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) {
Expand Down Expand Up @@ -570,6 +574,21 @@ public void setTurboModuleManager(JSIModule module) {
mTurboModuleRegistry = (TurboModuleRegistry) module;
}

@Override
public void setTurboModuleRegistry(TurboModuleRegistry turboModuleRegistry) {
mTurboModuleRegistry = turboModuleRegistry;
}

@Override
public void setFabricUIManager(UIManager fabricUIManager) {
mFabricUIManager = fabricUIManager;
}

@Override
public UIManager getFabricUIManager() {
return mFabricUIManager;
}

private void decrementPendingJSCalls() {
int newPendingCalls = mPendingJSCalls.decrementAndGet();
// TODO(9604406): handle case of web workers injecting messages to main thread
Expand Down

0 comments on commit 16fb64a

Please sign in to comment.