DocsPlaygroundBlogCommunityPackages
  • Playground
  • Blog
  • Community
  • Packages
  • X
  • Bluesky
  • GitHub
  • Forum
Language ManualAPISyntax LookupReact
Overview
Js
submodules
  • Array
  • Array2
  • BigInt
  • Blob
  • Console
  • Date
  • Dict
  • Exn
  • File
  • Float
  • Global
    • t
      intervalId
      D
    • t
      timeoutId
      D
    • v
      clearInterval
      D
    • v
      clearTimeout
      D
    • v
      setInterval
      D
    • v
      setIntervalFloat
      D
    • v
      setTimeout
      D
    • v
      setTimeoutFloat
      D
    • v
      encodeURI
      D
    • v
      decodeURI
      D
    • v
      encodeURIComponent
      D
    • v
      decodeURIComponent
      D
  • Int
  • Json
    • Kind
  • Map
  • Math
  • Null
  • Null_undefined
  • Nullable
  • Obj
  • Option
  • Promise
  • Promise2
  • Re
  • Result
  • Set
  • String
  • String2
  • TypedArray2
    • DataView
    • Float64Array
    • Float32Array
    • Uint32Array
    • Int32Array
    • Uint16Array
    • Int16Array
    • Uint8ClampedArray
    • Uint8Array
    • Int8Array
    • ArrayBuffer
    Typed_array
    • DataView
    • Float64_array
    • Float64Array
    • Float32_array
    • Float32Array
    • Uint32Array
    • Int32_array
    • Int32Array
    • Uint16Array
    • Int16Array
    • Uint8ClampedArray
    • Uint8Array
    • Int8Array
    • S
    • ArrayBuffer
    • Type
  • Types
  • Undefined
  • WeakMap
  • WeakSet
  • Docs / API / Js / Global

    Global

    Contains functions available in the global scope (window in a browser context)

    intervalId

    Deprecated

    RESCRIPT
    type intervalId = Global.intervalId

    Identify an interval started by Js.Global.setInterval.

    timeoutId

    Deprecated

    RESCRIPT
    type timeoutId = Global.timeoutId

    Identify timeout started by Js.Global.setTimeout.

    clearInterval

    Deprecated

    RESCRIPT
    let clearInterval: intervalId => unit

    Clear an interval started by Js.Global.setInterval

    Examples

    RESCRIPT
    /* API for a somewhat aggressive snoozing alarm clock */ let punchSleepyGuy = () => Js.log("Punch") let interval = ref(Js.Nullable.null) let remind = () => { Js.log("Wake Up!") punchSleepyGuy() } let snooze = mins => interval := Js.Nullable.return(Js.Global.setInterval(remind, mins * 60 * 1000)) let cancel = () => Js.Nullable.iter(interval.contents, intervalId => Js.Global.clearInterval(intervalId))

    clearTimeout

    Deprecated

    RESCRIPT
    let clearTimeout: timeoutId => unit

    Clear a timeout started by Js.Global.setTimeout.

    Examples

    RESCRIPT
    /* A simple model of a code monkey's brain */ let closeHackerNewsTab = () => Js.log("close") let timer = ref(Js.Nullable.null) let work = () => closeHackerNewsTab() let procrastinate = mins => { Js.Nullable.iter(timer.contents, timer => Js.Global.clearTimeout(timer)) timer := Js.Nullable.return(Js.Global.setTimeout(work, mins * 60 * 1000)) }

    setInterval

    Deprecated

    RESCRIPT
    let setInterval: (unit => unit, int) => intervalId

    Repeatedly executes a callback with a specified interval (in milliseconds) between calls. Returns a Js.Global.intervalId that can be passed to Js.Global.clearInterval to cancel the timeout.

    Examples

    RESCRIPT
    /* Will count up and print the count to the console every second */ let count = ref(0) let tick = () => { count := count.contents + 1 Js.log(Belt.Int.toString(count.contents)) } Js.Global.setInterval(tick, 1000)

    setIntervalFloat

    Deprecated

    RESCRIPT
    let setIntervalFloat: (unit => unit, float) => intervalId

    Repeatedly executes a callback with a specified interval (in milliseconds) between calls. Returns a Js.Global.intervalId that can be passed to Js.Global.clearInterval to cancel the timeout.

    Examples

    RESCRIPT
    /* Will count up and print the count to the console every second */ let count = ref(0) let tick = () => { count := count.contents + 1 Js.log(Belt.Int.toString(count.contents)) } Js.Global.setIntervalFloat(tick, 1000.0)

    setTimeout

    Deprecated

    RESCRIPT
    let setTimeout: (unit => unit, int) => timeoutId

    Execute a callback after a specified delay (in milliseconds). Returns a Js.Global.timeoutId that can be passed to Js.Global.clearTimeout to cancel the timeout.

    Examples

    RESCRIPT
    /* Prints "Timed out!" in the console after one second */ let message = "Timed out!" Js.Global.setTimeout(() => Js.log(message), 1000)

    setTimeoutFloat

    Deprecated

    RESCRIPT
    let setTimeoutFloat: (unit => unit, float) => timeoutId

    Execute a callback after a specified delay (in milliseconds). Returns a Js.Global.timeoutId that can be passed to Js.Global.clearTimeout to cancel the timeout.

    Examples

    RESCRIPT
    /* Prints "Timed out!" in the console after one second */ let message = "Timed out!" Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0)

    encodeURI

    Deprecated

    RESCRIPT
    let encodeURI: string => string

    URL-encodes a string.

    See encodeURI on MDN.

    decodeURI

    Deprecated

    RESCRIPT
    let decodeURI: string => string

    Decodes a URL-enmcoded string produced by encodeURI

    See decodeURI on MDN.

    encodeURIComponent

    Deprecated

    RESCRIPT
    let encodeURIComponent: string => string

    URL-encodes a string, including characters with special meaning in a URI.

    See encodeURIComponent on MDN.

    decodeURIComponent

    Deprecated

    RESCRIPT
    let decodeURIComponent: string => string

    Decodes a URL-enmcoded string produced by encodeURIComponent

    See decodeURIComponent on MDN.

    Types and values
    • t
      intervalId
      D
    • t
      timeoutId
      D
    • v
      clearInterval
      D
    • v
      clearTimeout
      D
    • v
      setInterval
      D
    • v
      setIntervalFloat
      D
    • v
      setTimeout
      D
    • v
      setTimeoutFloat
      D
    • v
      encodeURI
      D
    • v
      decodeURI
      D
    • v
      encodeURIComponent
      D
    • v
      decodeURIComponent
      D

    © 2025 The ReScript Project

    About
    • Community
    • ReScript Association
    Find us on