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