Gunslingor
08/12/2020, 9:07 PMexternal interface Block {
var id: String
var label: String
var select: Boolean
var attributes: Attributes
var content: Content //string or jsObject
var activate: Boolean
}
external interface Attributes {
var `class`: String
}
external interface Content {
var type: String
}
Gunslingor
08/12/2020, 9:49 PMclass Content {
lateinit var type: String
}
operator fun Content.invoke(block: () -> ()): () -> String {
return block
}
operator fun Content.invoke(block: String): String {
return block
}
Gunslingor
08/12/2020, 10:09 PMclass ContentObject {
lateinit var type: String
}
class Content {
fun invoke(block: ContentObject): ContentObject{
return block
}
fun invoke(block: String): String {
return block
}
}
That should'ver worked... I'm missing something.... Any for now, lolGunslingor
08/12/2020, 10:16 PMcontent = jsObject<Content> {
type = "image"
}
hmm... I guess that works well, IDE recognizes type now...string works... guess var content should be set to Any. Not sure there is any other way in kotin that doesn't end up looking like a Rube Goldberg machine.
I feel kotlin should offer a "multi-potential type object", lol. i.e. rather than Any I should be able to put anyOfThese(String, Content).Robert Jaros
08/12/2020, 11:09 PMRobert Jaros
08/12/2020, 11:10 PMGunslingor
08/12/2020, 11:12 PM