# createTransaction

Signature
`createTransaction(store?: Store): (callback: (txn: Transaction) => any) => any`

valdres-solid
Batch updates — subscribers fire once

Returns a function that runs a callback as a [transaction](https://valdres.dev/guides/transactions) on the current store: all updates apply atomically and subscribers fire once at the end. The callback receives `{ set, get, reset, del, unset }`.

## Usage

```tsx
import { atom } from "valdres"
import { createTransaction } from "valdres-solid"

const firstNameAtom = atom("")
const lastNameAtom = atom("")

function ResetForm() {
    const txn = createTransaction()
    const clear = () =>
        txn(({ reset }) => {
            reset(firstNameAtom)
            reset(lastNameAtom)
        })
    return <button onClick={clear}>Clear</button>
}
```

Pass a store to target one explicitly: `createTransaction(myStore)`.

## See also

- [Transactions guide](https://valdres.dev/guides/transactions) — semantics, nesting, and performance
- [useStore](https://valdres.dev/solid/useStore) — access the current store
