Skip to content

Notification

Types

getNotificationOptions

type getNotificationOptions = WebAPI.NotificationTypes.getNotificationOptions = {
mutable tag?: string,
}

Record fields

tag
option<string>

notificationAction

type notificationAction = WebAPI.NotificationTypes.notificationAction = {
action: string,
title: string,
icon?: string,
}

Record fields

action
string
title
string
icon
option<string>

notificationDirection

type notificationDirection = WebAPI.NotificationTypes.notificationDirection

notificationEvent

type notificationEvent = WebAPI.NotificationTypes.notificationEvent = {
type_: WebAPI.EventType.t,
target: Null.t<WebAPI.DOM.eventTarget>,
currentTarget: Null.t<WebAPI.DOM.eventTarget>,
eventPhase: int,
bubbles: bool,
cancelable: bool,
defaultPrevented: bool,
composed: bool,
isTrusted: bool,
timeStamp: float,
action: string,
notification: WebAPI.NotificationTypes.notification,
}

Record fields

type_

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

target

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

currentTarget

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

action
string

notificationOptions

type notificationOptions = WebAPI.NotificationTypes.notificationOptions = {
mutable dir?: WebAPI.NotificationTypes.notificationDirection,
mutable lang?: string,
mutable body?: string,
mutable tag?: string,
mutable icon?: string,
mutable badge?: string,
mutable silent?: Nullable.t<bool>,
mutable requireInteraction?: bool,
mutable data?: JSON.t,
mutable actions?: array<
WebAPI.NotificationTypes.notificationAction,
>,
mutable vibrate?: array<int>,
}

Record fields

lang
option<string>
body
option<string>
tag
option<string>
icon
option<string>
badge
option<string>
silent
option<Nullable.t<bool>>
requireInteraction
option<bool>
data
option<JSON.t>
vibrate
option<array<int>>

notificationPermission

type notificationPermission = WebAPI.NotificationTypes.notificationPermission

notificationPermissionCallback

type notificationPermissionCallback = WebAPI.NotificationTypes.notificationPermissionCallback

t

type t = WebAPI.NotificationTypes.notification = {
permission: WebAPI.NotificationTypes.notificationPermission,
title: string,
dir: WebAPI.NotificationTypes.notificationDirection,
lang: string,
body: string,
tag: string,
icon: string,
badge: string,
silent: Null.t<bool>,
requireInteraction: bool,
data?: JSON.t,
}

Record fields

title
string
badge
string
silent
Null.t<bool>
requireInteraction
bool
data
option<JSON.t>

Values

addEventListener

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. Read more on MDN

let addEventListener: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
~options: WebAPI.DOM.EventListener.addEventListenerOptions=?,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.toption<WebAPI.DOM.EventListener.addEventListenerOptions>

Return type

unit

addEventListenerWithCapture

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. Read more on MDN

let addEventListenerWithCapture: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.t

Return type

unit

asEventTarget

let asEventTarget: t => WebAPI.DOM.eventTarget

Parameters

t

Return type

WebAPI.DOM.eventTarget

close

let close: t => unit

Parameters

t

Return type

unit

dispatchEvent

Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. Read more on MDN

let dispatchEvent: (t, WebAPI.DOM.event) => bool

Parameters

tWebAPI.DOM.event

Return type

bool

make

let make: (~title: string, ~options: notificationOptions=?) => t

Parameters

stringoption<notificationOptions>

Return type

t

permission

let permission: notificationPermission

removeEventListener

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListener: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
~options: WebAPI.DOM.EventListener.options=?,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.toption<WebAPI.DOM.EventListener.options>

Return type

unit

removeEventListenerUseCapture

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListenerUseCapture: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
) => unit

Parameters

tWebAPI.EventType.tWebAPI.DOM.EventListener.t

Return type

unit

requestPermission

let requestPermission: (
~deprecatedCallback: notificationPermissionCallback=?,
) => promise<notificationPermission>

Parameters

option<notificationPermissionCallback>

Return type

promise<notificationPermission>