lewik
04/28/2018, 3:37 PMthis
as another class?
Now I'm writing
fun (){
val component = js("this") as VueComponent
component.doSmth()
}
I want
@JsChangeThis(VueComponent)
fun (){
this.doSmth()
}
bashor
04/28/2018, 4:19 PMlewik
04/28/2018, 4:19 PMbashor
04/28/2018, 4:20 PMbashor
04/28/2018, 4:20 PMbashor
04/28/2018, 4:21 PMlewik
04/28/2018, 4:23 PMthis
is changed at runtime. Without any hacks this
will resolves as POJsO, but I need it to be VueComponent (external declaration)bashor
04/28/2018, 4:48 PMlewik
04/28/2018, 4:58 PMvar vm = new Vue({
el: '#example',
data: {
message: 'Hello'
},
computed: {
// a computed getter
reversedMessage: function () {
// `this` points to the vm instance
return this.message.split('').reverse().join('')
}
}
})
bashor
04/28/2018, 5:27 PMlewik
04/28/2018, 5:39 PMthis
for annotated method and overriden methods. So we could use it in interfaces.bashor
04/28/2018, 5:43 PMlewik
04/28/2018, 5:43 PMbashor
04/28/2018, 5:43 PMlewik
04/28/2018, 5:47 PMthis
. (I don't know witch :) )lewik
04/28/2018, 5:48 PMthis
?bashor
04/28/2018, 5:59 PMYou can’t lock frontend within kotlin.We don’t think so and it’s the reason why the interop is important for us.
This hack could be used in other languagesDo you mean frameworks / libraries?
bashor
04/28/2018, 6:31 PMfun <T, R> fix(f: T.() -> R): T.() -> R {
val fs = f.toString()
val m = "function\\s*[^(]*\\(([^,)]*)\\s*,?\\s*([^)]*)\\)\\s*{".toRegex().find(fs)
println(m?.groupValues)
val firstArg = m?.groupValues?.get(1) ?: ""
val otherArgs = m?.groupValues?.get(2) ?: ""
val body = fs.substring(m?.groupValues?.get(0)?.length ?: 0, fs.length - 1)
val r = js("Function")(otherArgs, " $firstArg=this;" + body)
return r
}
bashor
04/28/2018, 6:32 PMval foo = fix<VueComponent, Int> {
componentProp + 1
}