import { debounce } from 'ngwr/utils';
const onResize = debounce(() => recalcLayout(), 150);
window.addEventListener('resize', onResize);
destroyRef.onDestroy(() => onResize.cancel());debounce
Runs a callback once calls have stopped for waitMs.
Usage
Call .cancel() on teardown to drop a pending call.
API
| Name | Description | Type | Default |
|---|---|---|---|
debounce(fn, waitMs) | Returns a wrapper that calls fn once waitMs pass with no new call. .cancel() drops a pending call. | (fn, ms) => WrDebouncedFn | — |