diff --git a/src/DOMAPI.res b/src/DOMAPI.res index c03f038..78549c9 100644 --- a/src/DOMAPI.res +++ b/src/DOMAPI.res @@ -9917,3 +9917,5 @@ type blobCallback = blob => unit type videoFrameRequestCallback = float => videoFrameCallbackMetadata => unit type frameRequestCallback = float => unit + +type timeoutId diff --git a/src/DOMAPI/Window.res b/src/DOMAPI/Window.res index 5445fdb..17a9dec 100644 --- a/src/DOMAPI/Window.res +++ b/src/DOMAPI/Window.res @@ -27,22 +27,20 @@ external btoa: (window, string) => string = "btoa" external atob: (window, string) => string = "atob" /** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) -*/ -@send -external setTimeout: (window, ~handler: string, ~timeout: int=?) => int = "setTimeout" +Executes a function after a delay given in milliseconds expires. -/** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ @send -external setTimeout2: (window, ~handler: unit => unit, ~timeout: int=?) => int = "setTimeout" +external setTimeout: (window, ~handler: unit => unit, ~timeout: int=?) => timeoutId = "setTimeout" /** +Cancels the execution of a timeout created with setTimeout. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */ @send -external clearTimeout: (window, int) => unit = "clearTimeout" +external clearTimeout: (window, timeoutId) => unit = "clearTimeout" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setInterval) diff --git a/src/Global.res b/src/Global.res index 61d2b36..2b7d808 100644 --- a/src/Global.res +++ b/src/Global.res @@ -260,19 +260,18 @@ external btoa: string => string = "btoa" external atob: string => string = "atob" /** -[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) -*/ -external setTimeout: (~handler: string, ~timeout: int=?) => int = "setTimeout" +Executes a function after a delay given in milliseconds expires. -/** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ -external setTimeout2: (~handler: unit => unit, ~timeout: int=?) => int = "setTimeout" +external setTimeout: (~handler: unit => unit, ~timeout: int=?) => timeoutId = "setTimeout" /** +Cancels the execution of a timeout created with setTimeout. + [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */ -external clearTimeout: int => unit = "clearTimeout" +external clearTimeout: timeoutId => unit = "clearTimeout" /** [Read more on MDN](https://developer.mozilla.org/docs/Web/API/Window/setInterval)