You are currently looking at the < v8.2.0 docs (Reason v3.6 syntax edition). You can find the latest API docs here.
(These docs cover all versions between v3 to v8 and are equivalent to the old BuckleScript docs before the rebrand)
Global
Provide bindings to JS global functions in global namespace.
REtype intervalId;
Identify an interval started by Js.Global.setInterval
.
REtype timeoutId;
Identify timeout started by Js.Global.setTimeout
.
clearInterval
RElet clearInterval: intervalId => unit;
Clear an interval started by Js.Global.setInterval
RE/* 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^, (. intervalId) =>
Js.Global.clearInterval(intervalId)
);
clearTimeout
RElet clearTimeout: timeoutId => unit;
Clear a timeout started by Js.Global.setTimeout
.
RE/* 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^, (. timer) => Js.Global.clearTimeout(timer));
timer := Js.Nullable.return(Js.Global.setTimeout(work, mins * 60 * 1000));
};
setInterval
RElet 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.
RE/* Will count up and print the count to the console every second */
let count = ref(0);
let tick = () => {
count := count^ + 1;
Js.log(Belt.Int.toString(count^));
};
Js.Global.setInterval(tick, 1000);
setIntervalFloat
RElet 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.
RE/* Will count up and print the count to the console every second */
let count = ref(0);
let tick = () => {
count := count^ + 1;
Js.log(Belt.Int.toString(count^));
};
Js.Global.setIntervalFloat(tick, 1000.0);
setTimeout
RElet 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.
RE/* Prints "Timed out!" in the console after one second */
let message = "Timed out!";
Js.Global.setTimeout(() => Js.log(message), 1000);
setTimeoutFloat
RElet 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.
RE/* Prints "Timed out!" in the console after one second */
let message = "Timed out!";
Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0);
encodeURI
RElet encodeURI: string => string;
URL-encodes a string.
decodeURI
RElet decodeURI: string => string;
Decodes a URL-enmcoded string produced by encodeURI.
encodeURIComponent
RElet encodeURIComponent: string => string;
URL-encodes a string, including characters with special meaning in a URI.
decodeURIComponent
RElet decodeURIComponent: string => string;
Decodes a URL-enmcoded string produced by encodeURIComponent