The DOM AbortSignal of the signal: options, from a Playwright.AbortController:
controller = Playwright.AbortController.new()
task = Task.async(fn -> Playwright.Locator.click(button, signal: Playwright.AbortController.signal(controller)) end)
Playwright.AbortController.abort(controller, "user cancelled")
{:error, %Playwright.AbortError{cause: "user cancelled"}} = Task.await(task)Runtime support (not ported from upstream): the part of the DOM class that Playwright uses
(aborted, reason, throwIfAborted, abort listeners). A signal is global, as in JS: it
belongs to no driver and works with calls on any. Its state lives in a public ETS table of the
application, so reads are lock-free from any process, and any process aborts.
Listeners run synchronously in the aborting process (as dispatchEvent runs them), so they
must not block: the client's listeners only send messages. A listener added after the abort
never runs (as in the DOM).
Deviation: a signal's rows (its reason, its listeners) are freed when the process that created it exits; JS frees them with the signal.
Summary
Types
An abort signal (Playwright.AbortController.signal/1).
Functions
signal.aborted: whether the controller aborted.
signal.addEventListener('abort', listener, options): listener (a 0-arity function) runs
in the aborting process when the signal aborts (see the moduledoc). A listener is added once
(equal functions are the same listener); once: true is implied, a signal aborts once.
signal.reason: the reason given to Playwright.AbortController.abort/2, nil while not aborted.
signal.removeEventListener('abort', listener).
signal.throwIfAborted(): raises the reason when aborted, if it is an exception, else an
AbortError with the reason as its cause (JS throws any value).
Types
@type t() :: %Playwright.AbortSignal{id: term()}
An abort signal (Playwright.AbortController.signal/1).
Functions
signal.aborted: whether the controller aborted.
signal.addEventListener('abort', listener, options): listener (a 0-arity function) runs
in the aborting process when the signal aborts (see the moduledoc). A listener is added once
(equal functions are the same listener); once: true is implied, a signal aborts once.
signal.reason: the reason given to Playwright.AbortController.abort/2, nil while not aborted.
signal.removeEventListener('abort', listener).
@spec throw_if_aborted(t()) :: :ok
signal.throwIfAborted(): raises the reason when aborted, if it is an exception, else an
AbortError with the reason as its cause (JS throws any value).