# Run modes (https://0758e0c7.effetch-query.pages.dev/docs/mutations/run-modes)

When a component starts a run while its previous run is in progress,
such as on a second click of a button, the mutation's `concurrent` decides what
happens. It applies to the runs of one use, such as one component's
`useMutation`. Separate uses, and `Mutation.run` calls, never affect each
other:

The examples import `api.ts` and `todos.ts` from [Getting started](https://0758e0c7.effetch-query.pages.dev/docs/getting-started).

- `true` (the default): runs overlap, and each completes.
- `false`: a new run interrupts the one in progress, whose optimistic
  writes are rolled back first.
- `"queue"`: runs go one at a time, in order. A queued run counts as in
  progress, but its `optimistic` runs when it starts, so a run that fails
  undoes only its own writes.
- `"drop"`: a run started while the one `result` shows is in progress is
  ignored. It never starts or calls anything, and its `run` resolves at
  once with an interrupted `Exit`. After `reset`, a new run starts.

`"drop"` suits a submit button, where a second click shouldn't send the
form twice:

```ts
import * as Schema from "effect/Schema";

import { Fetch } from "@monarcode/effetch";

import { Todo } from "./api.js";
import { api, todos } from "./todos.js";

export const createTodo = api.mutation(
  Fetch.endpoint("POST /todos", {
    input: Schema.Struct({ title: Schema.String }),
    output: Todo,
  }),
  // A click while the first run is saving does nothing.
  { concurrent: "drop", invalidates: [todos] },
);
```

To pick a mode for every mutation, set it on the client:
`mutations: { defaults: { concurrent: false } }`.