dukat
dukat copied to clipboard
Generate builder functions for SAM like interfaces
Examples:
external interface MyFunction {
@nativeInvoke
fun invoke(a: Int, b: String): Int
}
inline fun MyFunction(f: (a: Int, b: String) -> Int): MyFunction {
return f.unsafeCast<MyFunction>()
}
external interface MyFunctionWithVararg {
@nativeInvoke
fun invoke(a: Int, vararg b: String): Int
}
inline fun MyFunction(f: (a: Int, b: String) -> Int): MyFunctionWithVararg {
return { a -> f(a, js("arguments").slice(1)) }
}
Covered in a proposal we have in "DUKAT-9. Light-weight builder for (presumably) config-like interfaces".
Any update ?