feat(modules/NativeBridgeModule): map Unit return to null
This commit is contained in:
parent
d9c6281862
commit
f8f77e88a1
1 changed files with 6 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue