What is the rescript counterpart of the alert function of javascript?
There’s nothing built-in but it’s easy to bind as it’s just a global function which takes a single string
argument and returns unit
. You can find instructions here: Bind to Global JS Values | ReScript Language Manual
DZakh
July 22, 2022, 8:16pm
3
@yawaramin gave you a fishing rod, I’ll give you a fish
module Window = {
@scope("window") @val
external alert: string => unit = "alert"
}
Window.alert("Hello world!")
1 Like
spyder
July 24, 2022, 12:39pm
4
Also available in rescript-webapi
/* sessionStorage: accessed directly via Dom.Storage.sessionStorage */
@get external speechSynthesis: t_window => speechSynthesis = "speechSynthesis" /* experimental */
@get external status: t_window => string = "status"
@set external setStatus: (t_window, string) => unit = "status"
@get external statusbar: t_window => statusbar = "statusbar"
@get external toolbar: t_window => toolbar = "toolbar"
@get external top: t_window => Dom.window = "top"
@get
external window: t_window => t_window = "window" /* This is pointless I think, it's just here because window is the implicit global scope, and it's needed to be able to get a reference to it */
@send external alert: (t_window, string) => unit = "alert"
@send external blur: t_window => unit = "blur"
@send
external cancelIdleCallback: (t_window, idleCallbackId) => unit = "cancelIdleCallback" /* experimental, Cooperative Scheduling of Background Tasks */
@send external close: t_window => unit = "close"
@send external confirm: (t_window, string) => bool = "confirm"
@send external focus: t_window => unit = "focus"
@send external getComputedStyle: (t_window, Dom.element) => Dom.cssStyleDeclaration = "getComputedStyle"
@send
external getComputedStyleWithPseudoElement: (
t_window,
2 Likes