Trying to use compose for web, simply adding the d...
# compose-web
b
Trying to use compose for web, simply adding the dependency and I get lots of errors building along the lines of
e: java.lang.IllegalStateException: Duplicate live literal key found
. Is there a way to turn "live literals" off project wide instead of putting
@NoLiveLiterals
everwhere?
j
cc @Leland Richardson [G]
b
I sprinkled
@file:NoLiveLiterals
in the affected files which works around the issue. Let me know if sample code is helpful or this is a known issue.
Unfortunately now I'm stuck on a known issue: I need kotlinx serialization which isn't compatible at the moment (https://github.com/Kotlin/kotlinx.serialization/issues/1454).
l
you can disable for full project by adding to your build.gradle::
Copy code
composeOptions {
  useLiveLiterals false
}
it would be great if you could send the error message (which should include the key that is duplicated) and the code that caused it so we can fix it
c
That option would work on Android too right? Right now things are a little slow in compose and I wonder if I disable live literals if it'll help.
b
Case #1:
e: java.lang.IllegalStateException: Duplicate live literal key found: String$branch-2$when$fun-setLayoutParams$class-JGOViewImpl
It happens on this line in my method JGOViewImpl.setLayoutParams, where rootNode is an HTMLElement:
Copy code
rootNode.style.asDynamic().gridColumnStart = "1"
(I'm not surprised the asDynamic() is causing issues. I can easily replace it with
setProperty
in this case, which fixes the error)
Case #2 is
e: java.lang.IllegalStateException: Duplicate live literal key found: String$arg-0$call-onComplete$fun-$anonymous$$arg-0$call-$set-handler$$fun-$anonymous$$arg-0$call-apply$0$vararg$arg-0$call-arrayOf$arg-0$call-$set-buttons$$fun-showPicker$class-IonicHelper
And is also caused by
dynamic
:
Copy code
var handler: (value: dynamic) -> Unit
...
handler = {
    dialog.onComplete(it["column0"]["value"] as Int)
}
I guess all my issues are from
dynamic
, here's the last one:
e: java.lang.IllegalStateException: Duplicate live literal key found: String$arg-0$call-onComplete$fun-$anonymous$$arg-0$call-$set-handler$$fun-$anonymous$$arg-0$call-apply$0$vararg$arg-0$call-arrayOf$arg-0$call-$set-buttons$$fun-showPicker$class-IonicHelper
Copy code
fun NumberFormatOptions(
    style: String? = undefined,
    currency: String? = undefined
): dynamic {
    val o = js("({})")
    o["style"] = style // live literal error here
    o["currency"] = currency
    return o
}
b
For kotlinx.serialuzation issue, you can always move your @Serializable objects to a separate module without compose and depend on it
👌 1
b
@Big Chungus That would be a lot of work in my case, I think I'll wait for a bug fix
👍 1