Skip to content

EventAPI

Types

abortController

A controller object that allows you to abort one or more DOM requests as and when desired. See AbortController on MDN

type abortController = {signal: abortSignal}

Record fields

signal

Returns the AbortSignal object associated with this object. Read more on MDN

Module

There are methods and helpers defined in AbortController .

abortSignal

A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. See AbortSignal on MDN

type abortSignal = {aborted: bool, reason: JSON.t}

Record fields

aborted
bool

Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. Read more on MDN

reason
JSON.t

Module

There are methods and helpers defined in AbortSignal .

addEventListenerOptions

type addEventListenerOptions = {
mutable capture?: bool,
mutable passive?: bool,
mutable once?: bool,
mutable signal?: abortSignal,
}

Record fields

capture
option< bool >
passive
option< bool >
once
option< bool >
signal
option< abortSignal >

event

An event which takes place in the DOM. See Event on MDN

type event = {
type_: eventType,
target: Null.t<eventTarget>,
currentTarget: Null.t<eventTarget>,
eventPhase: int,
bubbles: bool,
cancelable: bool,
defaultPrevented: bool,
composed: bool,
isTrusted: bool,
timeStamp: float,
}

Record fields

type_

Returns the type of event, e.g. "click", "hashchange", or "submit". Read more on MDN

target
Null.t< eventTarget >

Returns the object to which event is dispatched (its target). Read more on MDN

currentTarget
Null.t< eventTarget >

Returns the object whose event listener's callback is currently being invoked. Read more on MDN

eventPhase
int

Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. Read more on MDN

bubbles
bool

Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise. Read more on MDN

cancelable
bool

Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. Read more on MDN

defaultPrevented
bool

Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. Read more on MDN

composed
bool

Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. Read more on MDN

isTrusted
bool

Returns true if event was dispatched by the user agent, and false otherwise. Read more on MDN

timeStamp
float

Returns the event's timestamp as the number of milliseconds measured relative to the time origin. Read more on MDN

Module

There are methods and helpers defined in Event .

eventInit

type eventInit = {
mutable bubbles?: bool,
mutable cancelable?: bool,
mutable composed?: bool,
}

Record fields

bubbles
option< bool >
cancelable
option< bool >
composed
option< bool >

eventListener

type eventListener<'event> = 'event => unit

eventListenerOptions

type eventListenerOptions = {mutable capture?: bool}

Record fields

capture
option< bool >

eventTarget

EventTarget is a DOM interface implemented by objects that can receive events and may have listeners for them. See EventTarget on MDN

type eventTarget = {}

Module

There are methods and helpers defined in EventTarget .

eventType

@unboxed
type eventType =
| @as("abort") Abort
| @as("auxclick") Auxclick
| @as("beforeinput") Beforeinput
| @as("beforetoggle") Beforetoggle
| @as("blur") Blur
| @as("cancel") Cancel
| @as("canplay") Canplay
| @as("canplaythrough") Canplaythrough
| @as("change") Change
| @as("click") Click
| @as("close") Close
| @as("contextlost") Contextlost
| @as("contextmenu") Contextmenu
| @as("contextrestored") Contextrestored
| @as("copy") Copy
| @as("cuechange") Cuechange
| @as("cut") Cut
| @as("dblclick") Dblclick
| @as("drag") Drag
| @as("dragend") Dragend
| @as("dragenter") Dragenter
| @as("dragleave") Dragleave
| @as("dragover") Dragover
| @as("dragstart") Dragstart
| @as("drop") Drop
| @as("durationchange") Durationchange
| @as("emptied") Emptied
| @as("ended") Ended
| @as("error") Error
| @as("focus") Focus
| @as("formdata") Formdata
| @as("input") Input
| @as("invalid") Invalid
| @as("keydown") Keydown
| @as("keypress") Keypress
| @as("keyup") Keyup
| @as("load") Load
| @as("loadeddata") Loadeddata
| @as("loadedmetadata") Loadedmetadata
| @as("loadstart") Loadstart
| @as("mousedown") Mousedown
| @as("mouseenter") Mouseenter
| @as("mouseleave") Mouseleave
| @as("mousemove") Mousemove
| @as("mouseout") Mouseout
| @as("mouseover") Mouseover
| @as("mouseup") Mouseup
| @as("paste") Paste
| @as("pause") Pause
| @as("play") Play
| @as("playing") Playing
| @as("progress") Progress
| @as("ratechange") Ratechange
| @as("reset") Reset
| @as("resize") Resize
| @as("scroll") Scroll
| @as("scrollend") Scrollend
| @as("securitypolicyviolation") Securitypolicyviolation
| @as("seeked") Seeked
| @as("seeking") Seeking
| @as("select") Select
| @as("slotchange") Slotchange
| @as("stalled") Stalled
| @as("submit") Submit
| @as("suspend") Suspend
| @as("timeupdate") Timeupdate
| @as("toggle") Toggle
| @as("volumechange") Volumechange
| @as("waiting") Waiting
| @as("webkitanimationend") Webkitanimationend
| @as("webkitanimationiteration") Webkitanimationiteration
| @as("webkitanimationstart") Webkitanimationstart
| @as("webkittransitionend") Webkittransitionend
| @as("wheel") Wheel
| @as("animationstart") Animationstart
| @as("animationiteration") Animationiteration
| @as("animationend") Animationend
| @as("animationcancel") Animationcancel
| @as("transitionrun") Transitionrun
| @as("transitionstart") Transitionstart
| @as("transitionend") Transitionend
| @as("transitioncancel") Transitioncancel
| @as("pointerover") Pointerover
| @as("pointerenter") Pointerenter
| @as("pointerdown") Pointerdown
| @as("pointermove") Pointermove
| @as("pointerup") Pointerup
| @as("pointercancel") Pointercancel
| @as("pointerout") Pointerout
| @as("pointerleave") Pointerleave
| @as("gotpointercapture") Gotpointercapture
| @as("lostpointercapture") Lostpointercapture
| @as("selectstart") Selectstart
| @as("selectionchange") Selectionchange
| @as("touchstart") Touchstart
| @as("touchend") Touchend
| @as("touchmove") Touchmove
| @as("touchcancel") Touchcancel
| Custom(string)