# Batch

> Talos next · Since 0.7

The instances an `updateAll` steps: index `k` is one instance, the same `k` in each list.

## Signature

```ts
export interface Batch<S = Record<string, any>> {
  /** How many instances. */
  readonly count: number
  /** Each instance's entity, a fresh handle every tick: compare with `id`, not `===`. */
  readonly entities: readonly EntityHandle[]
  /** Each instance's own `ctx.state`. */
  readonly states: readonly S[]
}
```

Import: `import type { Batch } from "@argus/api"`

## Members

| Member | Signature | Description |
|---|---|---|
| `count` | `readonly count: number` | How many instances. |
| `entities` | `readonly entities: readonly EntityHandle[]` | Each instance's entity, a fresh handle every tick: compare with `id`, not `===`. |
| `states` | `readonly states: readonly S[]` | Each instance's own `ctx.state`. |

## Example

The tested fixture `fixtures/recipes/many-entities/scenes/behaviors/beacon.ts`.

```ts
import type { Behavior } from "@argus/api"

/** A beacon: counts the drones that touch it. Only this beacon hears its touches (`emitTo`). */
interface State {
  touches: number
}

export default {
  init(ctx) {
    ctx.state.touches ??= 0
  },
  onEvent(ctx, ev) {
    if (ev.name === "touched") ctx.state.touches += 1
  },
} satisfies Behavior<State>
```
