---
title: "debounceCallback"
description: "Module-scoped one-shot debounce - schedule a callback that gets reset on each new call."
package: "@maz-ui/utils"
url: "https://maz-ui.com/ecosystem/utils/debounce-callback"
---

# debounceCallback

> Module-scoped one-shot debounce - schedule a callback that gets reset on each new call.

- Package: `@maz-ui/utils`
- Import: `import { debounceCallback } from '@maz-ui/utils/helpers/debounceCallback'`
- Web: https://maz-ui.com/ecosystem/utils/debounce-callback

Unlike [`debounce`](./debounce.md), which builds a debounced wrapper around a function, `debounceCallback` is a procedural helper: each call schedules a callback after `delay` ms, cancelling any previous pending callback.

**Warning: Shared module state**

`debounceCallback` uses a single module-level timer. All consumers of this function share the same timer slot, so calling it from two unrelated places will cancel each other. Use [`debounceId`](./debounce-id.md) for isolated debounces.

## Usage

```ts
import { debounceCallback } from '@maz-ui/utils'

debounceCallback(() => {
  console.log('runs only if no other call happens in the next 300 ms')
}, 300)
```

## API

```ts
function debounceCallback(
  callback: (...args: unknown[]) => unknown,
  delay: number,
): void
```

| Parameter  | Type       | Description                                |
| ---------- | ---------- | ------------------------------------------ |
| `callback` | `Function` | Function to run after the quiet window     |
| `delay`    | `number`   | Quiet window before firing, in milliseconds |
