# useSettle

Calls `onSettle` once `key` has stopped changing for `wait` milliseconds: the way to play a moment or announce a result once a burst of changes settles, rather than on each one. Every change of `key` starts the wait again, so a burst calls it once, for where the burst ended. The key the component is drawn with isn't a change, so nothing is called on mount; after the first change, every change counts, a return to the first key too. `onSettle` is read when it runs, so it sees the latest render's values.

Give it what the person changes, as a string or number (`JSON.stringify` a rule or a list); a value the clock or the service changes doesn't settle anything.

```
// Read the seats' prices out once the person stops pressing More or Fewer.
useSettle(seats, () => announce(t("announceSeats", { count: seats })), 600)
```

- Registry name: `use-settle` (`@candor/use-settle`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/use-settle

## Install

```bash
npx candor-ui add use-settle
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/use-settle`.
It brings in: tokens.

## Functions

### useSettle

```ts
useSettle(key: string | number | boolean | null | undefined, onSettle: () => void, wait: number)
```

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider`: its fixed strings in `strings`, its nouns in `nouns`; entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
