ylemoigne
05/10/2018, 3:22 AManton.bannykh
05/10/2018, 11:47 AM@JsName
is not an issue for you then? The foo
object does have a property id_a16eoc$_0
, but Kotlin expression foo.id
should translate to foo.id
in JS and delegate to the actual value at run time.ylemoigne
05/11/2018, 9:06 AMjsObject<TheInterface> { ... }
an copy fields manually but it's not very convenient and very error prone. I think that offering toPlainJsObject()
or something like that as an extension method would be great. Of course there is asJsObject()
from https://github.com/JetBrains/kotlin-wrappers/blob/master/kotlin-extensions/src/main/kotlin/kotlinext/js/Object.kt ; but as it just do a cast, it's not the intended behavior (the name that I give to the field is not the name in the JsObject
.anton.bannykh
05/11/2018, 9:22 AM> If you use a JS lib which explicitly forbid other type than plain JS objectIn that case it could be painful indeed. For the record, could you give an example? Better yet, could you file an issues here: https://youtrack.jetbrains.com/issues/KT
anton.bannykh
05/11/2018, 9:23 AManton.bannykh
05/11/2018, 9:24 AManton.bannykh
05/11/2018, 9:27 AMylemoigne
05/11/2018, 9:37 AManton.bannykh
05/11/2018, 9:40 AMylemoigne
05/11/2018, 9:44 AMylemoigne
05/11/2018, 9:48 AMinterface ClassAction<T : Any> : Action<KClass<out T>> {
override var type: KClass<out T>
var appAction: T
fun toPlainAction(): ClassAction<T> = jsObject {
this.type = this@ClassAction.type
this.appAction = this@ClassAction.appAction
}
}
. Then I write what redux call a Middleware
to automatically call toPlainAction
before it is passed to the api which require plain object.ylemoigne
05/11/2018, 9:52 AManton.bannykh
05/11/2018, 9:54 AManton.bannykh
05/11/2018, 9:54 AMylemoigne
05/11/2018, 9:59 AMylemoigne
05/11/2018, 10:13 AManton.bannykh
05/11/2018, 10:13 AMdanfma
05/15/2018, 7:14 PManton.bannykh
05/16/2018, 10:40 AMdanfma
05/16/2018, 12:26 PM