# revealStream

> Starts revealing `root`'s content from nothing.

```ts
import { revealStream } from "@sdxc/ui/chat";
```

Starts revealing `root`'s content from nothing. Text inside buttons and
`[data-stream-skip]` is left whole, and whitespace between blocks is kept, so the
finished reply is exactly the markup the server sent.

## Signature

```ts
revealStream(root: HTMLElement, options?: StreamRevealOptions): StreamReveal
```

Returns: The running reveal.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `root` | `HTMLElement` | The reply's element, already holding its final content. |
| `options?` | `StreamRevealOptions` | Pace, completion callback and an abort signal. |

## Examples

```tsx
revealStream(document.getElementById("reply-7")!, { onEnd: () => setIdle() })
```

## Used with it

The events, constants and types its module publishes, each imported from `@sdxc/ui/chat` too.

### StreamRevealOptions

Options for revealStream.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `interval?` | `number` | Milliseconds between ticks. @default 32 |
| `onEnd?` | `(end: StreamRevealEnd) => void` | Called once, when the whole reply has shown or StreamReveal.stop ran. |
| `signal?` | `AbortSignal` | Stops the reveal where it is when aborted, as StreamReveal.stop does. |

### StreamReveal

A running reveal.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `stop` | `void` | Freezes the reply at what has shown; the rest of it stays out of the page. |

### StreamRevealEnd

How a reveal finished.

#### Signature

```ts
type StreamRevealEnd = "done" | "stopped"
```

One of `"done"`, `"stopped"`.
