fable-browser icon indicating copy to clipboard operation
fable-browser copied to clipboard

Why Navigator.sendBeacon() is a TODO?

Open kittipatv opened this issue 4 years ago • 1 comments

Hi, What is the reason that Navigator.sendBeacon() is not available? I'm new to Fable (and F#) but the method signature looks simple. Can this be added?

https://github.com/fable-compiler/fable-browser/blob/master/src/Navigator/Browser.Navigator.fs#L135

kittipatv avatar Apr 03 '21 17:04 kittipatv

Hmm, tbh I don't remember 😅 Probably because I was updating the package noticed the API and was in doubt if the second data argument should be typed somehow or just obj. It accepts so many cases, that obj is probably fine, although I don't remember if we have a consistent approach for these cases in the repo. If you want to send a PR, ,aybe we can add it as:

abstract sendBeacon: url: string * ?data: obj -> unit

BTW, reporting missing APIs is very helpful. But in the case you need it and cannot wait for a new release you can use an extension:

open Fable.Core
open Browser.Types

type Navigator with
    [<Emit("$0.sendBeacon($1...)")>]
    member _.sendBeacon(url: string, ?data: obj): bool = jsNative

alfonsogarciacaro avatar Apr 05 '21 01:04 alfonsogarciacaro