Skip to content

coalesce

Returns a function that calls callback once on the next event loop turn, however many times it is called before then.

It is a debounce that, unlike one built on a timer, is not slowed while the window is hidden.

Import:

import { coalesce } from '@mnaoumov/typescript-lib/event-loop-turn';

Signature:

function coalesce(callback: () => void): () => void

Parameters:

Parameter Type Description
callback () => void The function to call.

Returns: () => void — The coalescing function.