For my project I have the ReactNative project and Android project created separately. We create a bundle from RN project and save it at the required location in Android project for creating the build.
Now because of the above reason, I can't run CodeGen to create Spec file for the module. Is it a requirement to be able to create TurboModules or can I create a TurboModule without a schema as well.
I've created the below files to test this functionality:
class DemoTurboModule(reactContext: ReactApplicationContext): ReactContextBaseJavaModule(reactContext), TurboModule {
companion object{
const val NAME = "DemoTurboModule"
}
override fun getName() = NAME
@ReactMethod
fun logMessage(message: String) {
Log.d("MyTurboModule", message)
}
}
Package:
class DemoTurboPackage: BaseReactPackage() {
override fun getModule(name: String, context: ReactApplicationContext): NativeModule? {
if(name == DemoTurboModule.NAME){
return DemoTurboModule(context)
} else {
return null
}
}
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
mapOf(
DemoTurboModule.NAME to ReactModuleInfo(
DemoTurboModule.NAME,
DemoTurboModule.NAME,
false,
false,
false,
true
)
)
}
}