# frameRefresh

> Keeps the frame that renders the host current: it reloads on a schedule, on an event, or both, and rests while the page is hidden.

```ts
import { frameRefresh } from "@sdxc/ui/mixins";
```

Reloads the host's enclosing frame every `every` milliseconds and whenever the `on` event
reaches the host. One reload runs at a time: an event during a reload queues one more. The
schedule pauses while the page is hidden and reloads once when it is shown again.

## Signature

```ts
frameRefresh(options: FrameRefresh.Options): MixinDescriptor<Element>
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `options` | `FrameRefresh.Options` |  |

## Examples

```tsx
<section mix={[frameRefresh({ every: 30_000 })]}>…</section>
```

```tsx
<div mix={[frameRefresh({ on: "app:saved", until: () => done })]}>…</div>
```

## Used with it

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

### FrameRefresh.Options

Configuration for frameRefresh; give `every`, `on`, or both.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `every?` | `number` | Milliseconds between the end of one reload and the start of the next. |
| `on?` | `string` | DOM event type that reloads the frame when it reaches the host, read once on insert. |
| `until?` | `() => boolean` | Read before each reload; once it answers `true` the host stops reloading the frame. |
