Skip to content

Commit

Permalink
Add AbortSignal and aborted binding (#47)
Browse files Browse the repository at this point in the history
* add AbortSignal and aborted binding

* Add reason field

Co-authored-by: Antonio Nuno Monteiro <[email protected]>

* Add reason to src/Fetch.mli

Co-authored-by: Antonio Nuno Monteiro <[email protected]>

---------

Co-authored-by: Antonio Nuno Monteiro <[email protected]>
  • Loading branch information
bryanthomaschen and anmonteiro authored Mar 12, 2024
1 parent 39c4f3f commit c5803ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Fetch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ type urlSearchParams (* URL *)
type blob
type file

module AbortSignal = struct
type t = signal

external aborted : t -> bool = "aborted" [@@mel.get]

external reason : t -> string Js.Nullable.t = "reason" [@@mel.get]
end

module AbortController = struct
type t = abortController

Expand Down
11 changes: 11 additions & 0 deletions src/Fetch.mli
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ type requestMethod =
| Patch
| Other of string

module AbortSignal : sig
type t = signal

external aborted : t -> bool = "aborted" [@@mel.get]


external reason : t -> string Js.Nullable.t = "reason" [@@mel.get]
(** A JavaScript value that indicates the abort reason, or undefined,
if not aborted. *)
end

module AbortController : sig
(* Experimental API *)
type t = abortController
Expand Down

0 comments on commit c5803ab

Please sign in to comment.