I cannot seem to find `window.navigator.sendBeacon...
# javascript
h
I cannot seem to find
window.navigator.sendBeacon
. In JS I usually just do
navigator.sendBeacon
. Does anyone in here have any knowledge to share?
l
Seems like it's not defined in Kotlin, use dynamic:
window.navigator.asDynamic().sendBeacon(...)
h
OK, thanks. Do all browsers implement this now? I have a check first:
if(navigator.sendBeacon) { ... }
, but I guess I can simply
js("")
the whole thing.
n
Better off developing a mapping file for the missing parts of the JS API not covered by Kotlin JS, which are going to be used in the program.
h
Maybe. But for small projects, a one-time
js("")
is better, I think.
n
Going the asDynamic() route for small projects is easier though (don't need to deal with the JS syntax checks that occur with the js function).