can i implement a Kotlin interface from JS?
# javascript
j
can i implement a Kotlin interface from JS?
n
Out of curiosity what are you using Kotlin JS for?
j
Just experimenting to gauge future potential
k
Yes, it's possible
You should mark your interface as
external
And then simply create an object in JS which provides all corresponding member functions and properties, with names maching those in the Kotlin interface
As for non-external interfaces, well, it's not recommended, but you still can do it. Please, look at classes generated by
kotlinc-js
. The only difference (addition) with pure JavaScript classes is additional static property called
$metadata$
. Also, you have to copy non-abstract functions manually.
j
Awesome I'll give it a try. Thanks!