feat(modules/NativeBridgeModule): map Unit return to null

This commit is contained in:
PalmDevs 2025-08-19 22:18:24 +07:00
parent d9c6281862
commit f8f77e88a1
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -7,6 +7,8 @@ import java.lang.reflect.Method
/**
* See for possible return types:
* https://github.com/facebook/react-native/blob/c23e84ae9/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/Arguments.kt#L19
*
* You may return a [Unit] and the resulting value will be `null`.
*/
typealias BridgeMethodCallback = (args: BridgeMethodArgs) -> Any?
@ -47,9 +49,11 @@ class NativeBridgeModule : Module() {
}
}
private fun Any?.toNativeObject(): Any? =
argumentsMakeNativeObject.invoke(null, this)
argumentsMakeNativeObject.invoke(null, when (this) {
Unit -> null
else -> this
})
override fun onInit(packageParam: XC_LoadPackage.LoadPackageParam) = with(packageParam) {
this@NativeBridgeModule.packageParam = packageParam