# reactionSync

> Makes every `ReactionBar` on the page answer at once: pressing a chip flips it and its count before the form posts in the background, a `ui:reaction-add` event adds or presses a chip, and a post the server refuses puts the row back.

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

Put on one element that stays on the page, such as an island's host: from then on every
reaction chip under `document` flips at once and posts in the background, and
`ui:reaction-add` events add reactions in place. Submits are claimed in the capture phase,
before any navigation handler sees them.

## Signature

```ts
reactionSync(): MixinDescriptor<HTMLElement>
```

Returns: A mixin with no visible effect on its host.

## Examples

```tsx
<span hidden mix={[reactionSync()]} />
```

## Used with it

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

### ReactionAddEvent

Dispatched on a `ReactionBar` (or any element inside the message holding one) to add the
reader's reaction: an existing chip is pressed, a missing one is cloned from the row's
`ReactionBar.Template`, and either posts through its form.

#### Signature

```ts
new ReactionAddEvent(detail: ReactionAddDetail)
```

#### Properties

| Property | Type | Description |
| --- | --- | --- |
| `detail` | `readonly ReactionAddDetail` |  |

### REACTION_ADD_EVENT

DOM event type that asks a `ReactionBar` to add, or press, a reaction.

#### Signature

```ts
const REACTION_ADD_EVENT = "ui:reaction-add" as const
```

### ReactionAddDetail

What a ReactionAddEvent asks for.

#### Members

| Member | Type | Description |
| --- | --- | --- |
| `emoji` | `string` | The emoji as the chip's form submits it: a character, or a custom's `:shortcode:`. |
| `label` | `string` | What the emoji is called, for the chip's accessible name. |
| `image?` | `string` | A custom emoji's image. |
| `toggle?` | `boolean` | Takes the reader's reaction off when they already reacted with this emoji. |
