ThrottleCallback

Creates a throttled version of a callback function. The callback will be executed at most once per specified wait interval.

Stateless utility

throttleCallback is a stateless utility that only limits callback execution frequency. For cases where you need to manage state transitions, consider using the throttled utility instead, which provides a reactive signal that tracks throttled state changes.

Usage

angular-ts
import { Component, output } from '@angular/core';
import { throttleCallback } from '@signality/core';

@Component({
  template: `
    <div (scroll)="handleScroll($event)">Scrollable content</div>
  `,
})
export class ScrollComponent {
  readonly throttleTime = input(300);
  readonly scrollChange = output<Event>();

  readonly handleScroll = throttleCallback((e: Event) => { 
    this.scrollChange.emit(e); 
  }, this.throttleTime); 
}

Parameters

ParameterTypeDescription
callbackT extends (...args: any[]) => anyThe function to throttle
waitMaybeSignal<number>Throttle interval in milliseconds
optionsWithInjectorOptional configuration (see Options below)

Options

OptionTypeDefaultDescription
injectorInjector-Optional injector for DI context

Return Value

Returns a throttled version of the callback function with the same signature.

SSR Compatibility

On the server, throttleCallback returns the original callback function unchanged. No throttling occurs, and the function executes immediately.

Type Definitions

typescript
function throttleCallback<T extends (...args: any[]) => any>(
  callback: T,
  wait: MaybeSignal<number>,
  options?: WithInjector
): T;
Edit this page on GitHub Last updated: Mar 19, 2026, 23:28:23