# abortable-element

AbortController ownership for Neutron elements — cancel in-flight
work cleanly when a newer request supersedes it.

## Features

- **Owned controller** Fresh `AbortController` per in-flight cycle
- **doAbort()** Abort current work and rotate a new controller
- **Fetch-ready** Pass `abortController.signal` into `fetch` /
  template loads

## Installation


`@excom/abortable-element` v0.1.4

```bash
pnpm add @excom/abortable-element
```

```bash
npm install @excom/abortable-element
```

```bash
yarn add @excom/abortable-element
```

### Import

```ts
import { /* … */ } from "@excom/abortable-element";
```



## Usage

Compose `AbortableElement` and pass `abortController.signal` into
async work. Call `doAbort()` when that work should be cancelled (e.g.
`template-ref` changed). `RenderableElement` already does this for
template fetches.

```ts
import { Neutron } from "@excom/neutron";
import { AbortableElement } from "@excom/abortable-element";

export const FetchOnce = Neutron.compose([
  AbortableElement,
  Neutron({
    tag: "fetch-once",
    props: { src: String },
  }),
])
  .onPropChanged("src", async (el) => {
    el.doAbort();
    if (!el.src) return;
    const res = await fetch(el.src, {
      signal: el.abortController.signal,
    });
    // …
  });

FetchOnce.define();
```

There are no public attributes — the controller is internal. See
[renderable-element](/packages/renderable-element) for the primary
consumer.

### API Reference

## Release notes

### 0.1.1 (2026-09-23)

- Ship only dist (and declared extras) in the npm tarball; drop build logs, tests and sources
