Skip to main content

Debounced Signal

Overview

The debouncedSignal function creates a debounced signal that updates its value after a specified timeout.

Parameters

ParameterTypeDefaultDescription
inputSignal<T>N/AThe input signal whose value will be debounced.
timeOutMsnumber0The debounce timeout in milliseconds. Defaults to 0.

Returns

TypeDescription
Signal<T>A new signal that updates its value after the specified debounce timeout.

Example

const input = signal('');
const debounced = debouncedSignal(input, 1000);

constructor() {
effect(() => {
console.log(debounced());
// will log the input value after 1 second of inactivity.
});
}
...
<input [ngModel]="input()" (ngModelChange)="input.set($event)">