diff --git a/Changes.md b/Changes.md index 5f539a081..3ab3c8593 100644 --- a/Changes.md +++ b/Changes.md @@ -101,6 +101,8 @@ Unreleased pipe-last ([#968](https://github.com/melange-re/melange/pull/968)) - BREAKING(runtime): Remove unnecessary `unit` argument from `Js.Math.atan2` ([#972](https://github.com/melange-re/melange/pull/972)) +- BREAKING(runtime): Add labeled arguments to the callbacks in `Js.Global` + ([#973](https://github.com/melange-re/melange/pull/973)) 2.2.0 2023-12-05 --------------- diff --git a/jscomp/runtime/js_global.ml b/jscomp/runtime/js_global.ml index dcabcadf9..53bbeaf4e 100644 --- a/jscomp/runtime/js_global.ml +++ b/jscomp/runtime/js_global.ml @@ -32,7 +32,6 @@ type timeoutId (** Identify timeout started by {! setTimeout} *) external clearInterval : intervalId -> unit = "clearInterval" - (** Clear an interval started by {! setInterval} {[ @@ -55,7 +54,6 @@ let cancel () = *) external clearTimeout : timeoutId -> unit = "clearTimeout" - (** Clear a timeout started by {! setTimeout} {[ (* A simple model of a code monkey's brain *) @@ -73,8 +71,7 @@ let procrastinate mins = @see MDN *) -external setInterval : (unit -> unit) -> int -> intervalId = "setInterval" - +external setInterval : f:(unit -> unit) -> int -> intervalId = "setInterval" (** {i Repeatedly} executes a callback with a specified interval (in milliseconds) between calls {b Return} an {! intervalId} that can be passed to {! clearInterval} to cancel the timeout @@ -94,9 +91,8 @@ let _ = ]} *) -external setIntervalFloat : (unit -> unit) -> float -> intervalId +external setIntervalFloat : f:(unit -> unit) -> float -> intervalId = "setInterval" - (** {i Repeatedly} executes a callback with a specified interval (in milliseconds) between calls {b Return} an {! intervalId} that can be passed to {! clearInterval} to cancel the timeout @@ -116,8 +112,7 @@ let _ = ]} *) -external setTimeout : (unit -> unit) -> int -> timeoutId = "setTimeout" - +external setTimeout : f:(unit -> unit) -> int -> timeoutId = "setTimeout" (** Execute a callback after a specified delay (in milliseconds) {b returns} a {! timeoutId} that can be passed to {! clearTimeout} to cancel the timeout @@ -134,8 +129,7 @@ let _ = ]} *) -external setTimeoutFloat : (unit -> unit) -> float -> timeoutId = "setTimeout" - +external setTimeoutFloat : f:(unit -> unit) -> float -> timeoutId = "setTimeout" (** Execute a callback after a specified delay (in milliseconds) {b returns} a {! timeoutId} that can be passed to {! clearTimeout} to cancel the timeout @@ -153,28 +147,24 @@ let _ = *) external encodeURI : string -> string = "encodeURI" - (** URL-encodes a string. @see MDN *) external decodeURI : string -> string = "decodeURI" - (** Decodes a URL-enmcoded string produced by [encodeURI] @see MDN *) external encodeURIComponent : string -> string = "encodeURIComponent" - (** URL-encodes a string, including characters with special meaning in a URI. @see MDN *) external decodeURIComponent : string -> string = "decodeURIComponent" - (** Decodes a URL-enmcoded string produced by [encodeURIComponent] @see MDN diff --git a/jscomp/test/js_global_test.ml b/jscomp/test/js_global_test.ml index 13764fee5..cc1dfc808 100644 --- a/jscomp/test/js_global_test.ml +++ b/jscomp/test/js_global_test.ml @@ -3,13 +3,13 @@ open Js.Global let suites = Mt.[ ("setTimeout/clearTimeout sanity check", (fun _ -> - let handle = setTimeout (fun () -> ()) 0 in + let handle = setTimeout ~f:(fun () -> ()) 0 in clearTimeout handle; Ok true )); ("setInerval/clearInterval sanity check", (fun _ -> - let handle = setInterval (fun () -> ()) 0 in + let handle = setInterval ~f:(fun () -> ()) 0 in clearInterval handle; Ok true ));