# `PlaywrightEx.AbortController`
[🔗](https://github.com/ftes/playwright_ex/blob/v0.17.0-rc.5/lib/playwright_ex/abort_controller.ex#L1)

The DOM `AbortController`: aborts the calls given its `signal/1` as `signal:` option.

    controller = PlaywrightEx.AbortController.new()
    signal = PlaywrightEx.AbortController.signal(controller)
    Task.start(fn -> Process.sleep(1000); PlaywrightEx.AbortController.abort(controller) end)
    {:error, %PlaywrightEx.AbortError{}} = PlaywrightEx.Locator.click(button, signal: signal, timeout: 0)

Any process can abort. The calls fail with `PlaywrightEx.AbortError`, whose
`cause` is the reason; matchers fail like a timeout ("The assertion was aborted").

Runtime support (not ported from upstream). A controller is global, as in JS: its signal works
with calls on any driver (see `PlaywrightEx.AbortSignal`).

# `t`

```elixir
@type t() :: %PlaywrightEx.AbortController{signal: PlaywrightEx.AbortSignal.t()}
```

An abort controller.

# `abort`

```elixir
@spec abort(t(), term()) :: :ok
```

`controller.abort(reason)`: aborts the signal, from any process; its listeners have run when it
returns (see `PlaywrightEx.AbortSignal`). Without a reason
(`nil`), the reason is an `AbortError` "This operation was aborted" (JS: a `DOMException` of that
name). Aborting twice does nothing.

# `new`

```elixir
@spec new() :: t()
```

`new AbortController()`.

# `signal`

```elixir
@spec signal(t()) :: PlaywrightEx.AbortSignal.t()
```

`controller.signal`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
