From 86bf8d1e893803aacfad8e2ebc4c92eca71286e8 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 28 Jul 2023 06:08:53 -0700 Subject: [PATCH] Migrate TurboModuleRegistry to kotlin (#38593) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38593 In this diff I'm migrating TurboModuleRegistry to kotlin changelog: [internal] internal Reviewed By: christophpurrer Differential Revision: D47382872 fbshipit-source-id: 9249a269d9253555b9fda8c665da57f62c825821 --- ...leRegistry.java => TurboModuleRegistry.kt} | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/{TurboModuleRegistry.java => TurboModuleRegistry.kt} (73%) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.kt similarity index 73% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.kt index a255d1a4140..981681105ed 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModuleRegistry.kt @@ -5,12 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.turbomodule.core.interfaces; +package com.facebook.react.turbomodule.core.interfaces -import androidx.annotation.Nullable; -import com.facebook.react.bridge.NativeModule; -import java.util.Collection; -import java.util.List; +import com.facebook.react.bridge.NativeModule +import java.util.Collection /** * Interface to allow for creating and retrieving NativeModules. Why is this this class prefixed @@ -18,25 +16,23 @@ import java.util.List; * already is a NativeModuleRegistry (a part of the legacy architecture). Once that class is * deleted, we should rename this interface accordingly. */ -public interface TurboModuleRegistry { +interface TurboModuleRegistry { /** * Return the NativeModule instance that has that name `moduleName`. If the `moduleName` * TurboModule hasn't been instantiated, instantiate it. If no TurboModule is registered under * `moduleName`, return null. */ - @Nullable - NativeModule getModule(String moduleName); + fun getModule(moduleName: String): NativeModule? /** Get all instantiated NativeModules. */ - Collection getModules(); + val modules: Collection /** Has the NativeModule with name `moduleName` been instantiated? */ - boolean hasModule(String moduleName); - + fun hasModule(moduleName: String): Boolean /** * Return the names of all the NativeModules that are supposed to be eagerly initialized. By * calling getModule on each name, this allows the application to eagerly initialize its * NativeModules. */ - List getEagerInitModuleNames(); + val eagerInitModuleNames: List }