And my next Question: I assume that the Kotlin bin...
# javascript
t
And my next Question: I assume that the Kotlin bindings for Broser/DOM api is continius development to implement new functions added to the standart. But if don't want to wait until the Kotlin bindings get updated, how do i call a Javascript function? My current specific problem is, how do i call the function from the popover api on an Element?
j
Two general approaches: • Call asDynamic and then call it with no safety • Create an external interface with the function, call unsafeCast<YourInterface>().theApi()
t
Latest browser API is already here (in
kotlin-browser
)
🙌 1
If API supported by 2 main browsers - it will be in
kotlin-browser
> Call asDynamic and then call it with no safety Main problem of
asDynamic
- it will not receive compilation warning after library update 😞
Right now in
kotlin-browser
we cover 100% of browser API (supported by 2+ main browsers) and unsafe
asDynamic
and
unsafeCast
calls aren't expected. If you will find stable browser API, missed in
kotlin-browser
- please report an issue 😉.
To hide DOM API from
stdlib-js
:
Copy code
kotlin.js.stdlib.dom.api.included=false
j
I did say it had no safety!
👌 1
t
Extension (with
asDynamic()
call inside) is better solution - it will produce warning, when property will be added
t
Ok now im confused: there is kotlinx-browser and then there is your kotlin-browser What’s the difference?
t
kotlin-browser
is up-to-date and more strict. Other libraries from Kotlin Wrappers use
kotlin-browser
🙌 1
t
But new APIs function will come to kotlinx-browser after some time?
And how should i declare a dependcy on kotlin-browser? Both variants from here https://kotlinlang.org/docs/js-project-setup.html#dependencies throw errors while rebuilding/reloading the gradel config
t
Ok got it running. Where should i put
kotlin.js.stdlib.dom.api.included=false
?
t
gradle.properties
🙌 1
t
Ah yes stupid me forgot that this simple key-prop syntax belongs to properties files.
And may i hope for another answer? (if you not already annoyed by me) How do i specify the CanvasRenderingContext2DSettings options for the HTMLCanvasElement.getContext() function? As the Settings Type is a sealed interface i cannot create a object from it, and i didn't find constants already defined for it.
t
Copy code
settings = jso {
    // configuration
}
🙌 1
1