defer
Commons
stable
Schedules a callback after a given timeout (ms) using window.setTimeout in the browser. When called during SSR or with timeout = 0, the callback runs synchronously. Returns a cancel function.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- timeoutrequisnumber
- Delay in milliseconds before the callback is invoked. Pass 0 to run synchronously.
- cbrequis() => void
- The function to call after the timeout.
API
Valeur de retour
La valeur retournée par cet util.
- A cancel function. Calling it clears the pending timeout so the callback is never invoked.
Usage
Exemples
Extraits de code prêts à coller.
Delayed execution with cancel