Edoardo Luppi
07/02/2023, 4:54 PMfun interface
to an arrow function?
Given this example:
@JsExport
public fun interface ExampleFun {
public fun doSomething(str: String)
}
@JsExport
public interface ExampleUsage {
public fun example(fn: ExampleFun)
}
I can see the resulting TS declaration is:
export declare interface ExampleFun {
doSomething(str: string): void;
readonly __doNotUseOrImplementIt: {
readonly "com.hcl.mainframe.zproto.ExampleFun": unique symbol;
};
}
export declare interface ExampleUsage {
example(fn: ExampleFun): void;
readonly __doNotUseOrImplementIt: {
readonly "com.hcl.mainframe.zproto.ExampleUsage": unique symbol;
};
}
However it would be more meaningful to translate it to an arrow function.
It also allows better interoperability between Kotlin and Java, being that in Java a fun interface can be used as lambda.turansky
07/02/2023, 8:26 PMHowever it would be more meaningful to translate it to an arrow function.What if I have 2 fun interfaces and implement both in my class? How it will work? 🙂
Edoardo Luppi
07/02/2023, 8:48 PMturansky
07/02/2023, 8:51 PMfun interface A {
fun doA(): AAA
}
fun interface B {
fun doB(): BBB
}
class C: A, B {
// implementation
}
Edoardo Luppi
07/02/2023, 8:53 PMpublic interface ExampleUsage {
public fun example(fn: A)
}
after transforming to an arrow function the code wouldn't work anymore.
Yeah that's trueEdoardo Luppi
07/02/2023, 8:55 PMfun interface
for hierarchies in KotlinJS?
Or maybe an additional Js*
annotationArtem Kobzar
07/03/2023, 7:40 AMEdoardo Luppi
07/03/2023, 7:50 AM