Skip to content

Commit 2d8d333

Browse files
committed
Extracted AbortController. Can't extract other fetch submodules without changing the API (or a lot of unnecessary effort).
1 parent 332f30e commit 2d8d333

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
type signal
2+
type t = {signal: signal}
3+
4+
@new external make: unit => t = "AbortController"
5+
@send external abort: t => unit = "abort"
6+
7+
/** For compatibility. Prefer the record field. */
8+
@get external signal: t => signal = "signal"

src/Webapi/Webapi__Fetch.res

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,27 @@
1+
module AbortController = Webapi__Fetch__AbortController
2+
3+
/* * Alias for anyone upgrading */
4+
module FormData = Webapi__FormData
15
type body
26
type bodyInit
37
type headers
48
type headersInit
59
type response
610
type request
711
type requestInit
8-
type abortController
9-
type signal
12+
type abortController = AbortController.t
13+
type signal = AbortController.signal
1014

1115
/* external */
1216
type arrayBuffer /* TypedArray */
1317
type bufferSource /* Web IDL, either an arrayBuffer or arrayBufferView */
14-
type formData = Webapi__FormData.t/* XMLHttpRequest */
18+
type formData = FormData.t /* XMLHttpRequest */
1519
type readableStream = Webapi__ReadableStream.t /* Streams */
1620
type urlSearchParams /* URL */
1721

1822
type blob = Webapi__Blob.t
1923
type file = Webapi__File.t
2024

21-
module AbortController = {
22-
type t = abortController
23-
24-
@get external signal: t => signal = "signal"
25-
@send external abort: t => unit = "abort"
26-
@new external make: unit => t = "AbortController"
27-
}
28-
2925
type requestMethod =
3026
| Get
3127
| Head
@@ -437,9 +433,6 @@ module Response = {
437433
@send external clone: t => t = "clone"
438434
}
439435

440-
/** Alias for anyone upgrading */
441-
module FormData = Webapi__FormData
442-
443436
@val external fetch: string => Js.Promise.t<response> = "fetch"
444437
@val external fetchWithInit: (string, requestInit) => Js.Promise.t<response> = "fetch"
445438
@val external fetchWithRequest: request => Js.Promise.t<response> = "fetch"

src/Webapi/Webapi__Fetch.resi

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
module AbortController = Webapi__Fetch__AbortController
2+
3+
/** Alias for anyone upgrading */
4+
module FormData = Webapi__FormData
15
type body
26
type bodyInit
37
type headers
@@ -9,11 +13,11 @@ type requestInit
913
/* external */
1014
type arrayBuffer /* TypedArray */
1115
type bufferSource /* Web IDL, either an arrayBuffer or arrayBufferView */
12-
type formData = Webapi__FormData.t /* XMLHttpRequest */
16+
type formData = FormData.t /* XMLHttpRequest */
1317
type readableStream /* Streams */
1418
type urlSearchParams /* URL */
15-
type abortController
16-
type signal
19+
type abortController = AbortController.t
20+
type signal = AbortController.signal
1721

1822
@@ocaml.text(" File API ")
1923

@@ -32,18 +36,6 @@ type requestMethod =
3236
| Patch
3337
| Other(string)
3438

35-
module AbortController: {
36-
/* Experimental API */
37-
type t = abortController
38-
39-
/* Experimental API */
40-
@get external signal: t => signal = "signal"
41-
/* Experimental API */
42-
@send external abort: t => unit = "abort"
43-
/* Experimental API */
44-
@new external make: unit => t = "AbortController"
45-
}
46-
4739
type referrerPolicy =
4840
| None
4941
| NoReferrer
@@ -236,9 +228,6 @@ module Response: {
236228
@send external text: t => Js.Promise.t<string> = "text"
237229
}
238230

239-
/** Alias for anyone upgrading */
240-
module FormData = Webapi__FormData
241-
242231
@val external fetch: string => Js.Promise.t<response> = "fetch"
243232
@val external fetchWithInit: (string, requestInit) => Js.Promise.t<response> = "fetch"
244233
@val external fetchWithRequest: request => Js.Promise.t<response> = "fetch"

0 commit comments

Comments
 (0)