Undo breaking change on Dynamic.type and Dynamic.isNull (#45378)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45378

Kotlin consumers of those APIs are forced with this breaking change:

```
# Before thanks to Java property conversion
Dynamic.type
# After
Dynamic.getType()
```
This restores the old more idiomatic API by moving those 2 funcitons to be vals.

Changelog:
[Android] [Fixed] - Undo breaking change on Dynamic.type and Dynamic.isNull

Reviewed By: javache

Differential Revision: D59631783

fbshipit-source-id: 8d720af34e104ee0e4f3120302a4a84fc17a7b1c
This commit is contained in:
Nicola Corti
2024-07-11 12:19:55 -07:00
committed by Facebook GitHub Bot
parent 384983025a
commit 5e31b45fc7
2 changed files with 6 additions and 6 deletions
@@ -12,6 +12,10 @@ package com.facebook.react.bridge
* pass one of multiple types down to the native layer.
*/
public interface Dynamic {
public val type: ReadableType
public val isNull: Boolean
public fun asArray(): ReadableArray
public fun asBoolean(): Boolean
@@ -24,9 +28,5 @@ public interface Dynamic {
public fun asString(): String
public fun getType(): ReadableType
public fun isNull(): Boolean
public fun recycle(): Unit
}
@@ -25,7 +25,7 @@ public class LengthPercentage(
public companion object {
@JvmStatic
public fun setFromDynamic(dynamic: Dynamic): LengthPercentage? {
return when (dynamic.getType()) {
return when (dynamic.type) {
ReadableType.Number -> {
val value = dynamic.asDouble()
if (value >= 0f) {
@@ -54,7 +54,7 @@ public class LengthPercentage(
}
}
else -> {
FLog.w(ReactConstants.TAG, "Unsupported type for radius property: ${dynamic.getType()}")
FLog.w(ReactConstants.TAG, "Unsupported type for radius property: ${dynamic.type}")
null
}
}