https://kotlinlang.org logo
e

Edoardo Luppi

07/02/2023, 8:49 PM
Wonder how you deal with such scenario:
Copy code
Promise { resolve, _ ->
  resolve("a string")
}.catch {
  12
}.then {
  val v: Int = it
  println(v) // Expected an Int, but a string is received
}
b

Big Chungus

07/02/2023, 8:51 PM
Sealed box class if you really must mix the types. Otherwise it's best to avoid mixing types in Promise
Catch block is meant to provide a sensible default value, not an entirely different type.
t

turansky

07/02/2023, 8:58 PM
catch
call signature is invalid right now. We will try to fix it here (with other
Promise
problems). In described example second
then
will receive data with type
String | Int
.
👀 1
e

Edoardo Luppi

07/02/2023, 9:02 PM
@Big Chungus that's reasonable! Thanks. Although you know, it's something you need to be very careful about now. @turansky oh nice. Although how are you representing
String | Int
?
Any
?
t

turansky

07/02/2023, 9:10 PM
Comparable<*>
expected
✔️ 1
e

Edoardo Luppi

07/02/2023, 9:46 PM
Thanks @turansky!
t

turansky

07/04/2023, 11:01 PM
Implemented 😉 Expected in next release (probably tomorrow).
Released in Kotlin Wrappers
pre.585
e

Edoardo Luppi

07/05/2023, 10:56 AM
Thanks @turansky! Awesome!
6 Views