useDelay

Commons
stable

Manages open/close delay timing for overlay components. Reads openDelay and closeDelay from IDelayProps and exposes runOpenDelay / runCloseDelay helpers that debounce state transitions. Each new call cancels any in-flight delay, preventing race conditions when hover enters and leaves quickly.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

Interfaces consommées

IDelayProps

API

Paramètres

Paramètres d'entrée acceptés par ce composable.

props
requis
IDelayProps
Props object containing openDelay and closeDelay (number | string). Both are optional; missing values default to 0 (no delay).
cb
(value: boolean) => void
Optional callback invoked with true when the open delay fires, false when the close delay fires. Use this to drive a reactive open state instead of awaiting the promise.

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

clearDelay
Cancel the currently scheduled delay without triggering the callback.
runOpenDelay
Start the open delay. Cancels any previously scheduled delay. Resolves with true after props.openDelay ms and fires cb(true).
runCloseDelay
Start the close delay. Cancels any previously scheduled delay. Resolves with false after props.closeDelay ms and fires cb(false).

Usage

Exemples

Extraits de code prêts à coller.

Tooltip with open/close delay

vue

Await the delay promise

vue