AbortSignal

Abort Signal

Abort signals are used to trigger an abort of an operation; from MDN:

The AbortSignal interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object.

Note that AbortSignal is also an EventTarget; the event abort will be emitted when the signal is aborted.

AbortSignal on MDN AbortController on MDN

See also

Companion AbortController class

Inheritors

Types

Link copied to clipboard
interface Factory

Models the structure expected/provided for constructors of an AbortSignal.

Properties

Link copied to clipboard
abstract val aborted: Boolean

Read-only property indicating whether the signal has been aborted; from MDN:

Link copied to clipboard
abstract val reason: Any?

Read-only property indicating the reason the operation was aborted; from MDN:

Functions

Link copied to clipboard
abstract fun addEventListener(type: String, listener: EventListener)
abstract fun addEventListener(type: String, options: AddEventListenerOptions, listener: EventListener)
abstract fun addEventListener(type: String, listener: Value, options: Value?)

Adds a new handler for the type event. Any given listener is added only once per type and per capture option value.

Link copied to clipboard
abstract fun dispatchEvent(event: Event): Boolean

Dispatches the event to the list of handlers for Event.type.

Link copied to clipboard
abstract fun removeEventListener(type: String, listener: EventListener)
abstract fun removeEventListener(type: String, listener: Value)
abstract fun removeEventListener(type: String, listener: EventListener, options: RemoveEventListenerOptions)
abstract fun removeEventListener(type: String, listener: EventListener, options: Value)
abstract fun removeEventListener(type: String, listener: Value, options: Value)

Removes the listener from the list of handlers for event type.

Link copied to clipboard
abstract fun throwIfAborted()

Throws the AbortSignal's reason for aborting, if aborted; from MDN: