Wonder how you deal with such scenario: ```Promise...
# javascript
e
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
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
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
@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
Comparable<*>
expected
✔️ 1
e
Thanks @turansky!
t
Implemented 😉 Expected in next release (probably tomorrow).
Released in Kotlin Wrappers
pre.585
e
Thanks @turansky! Awesome!