WICG / pending-beacon

A better beaconing API
Other
43 stars 8 forks source link

Pending(Get|Post)Beacon vs PendingBeacon("(Get|Post)", .... #59

Closed sefeng211 closed 9 months ago

sefeng211 commented 1 year ago

Have we considered to shape the API as PendingBeacon("Get", ...) and PendingBeacon("Post", ...)? This would match what the fetch and XHR do. It seems uncommon with the current setup.

mingyc commented 1 year ago

cc @fergald It is mainly for easier type safety to make the API shape look like this.

fergald commented 1 year ago

If we made them the same class then we would have to specify that certain methods (like setUrl or setData) will raise exceptions when called on the wrong kind. Making them different classes avoids that and for typescript coders, it becomes a compile-time error to call setUrl of a POST beacon.

mingyc commented 9 months ago

The API is now repurposed as fetchLater() which supports both HTTP methods. https://github.com/whatwg/fetch/pull/1647