MCPcopy
hub / github.com/angular/angular / normalizeDebouncer

Function normalizeDebouncer

packages/forms/signals/src/api/rules/debounce.ts:40–58  ·  view source on GitHub ↗
(
  debouncer: number | 'blur' | Debouncer<TValue, TPathKind>,
)

Source from the content-addressed store, hash-verified

38}
39
40function normalizeDebouncer<TValue, TPathKind extends PathKind>(
41 debouncer: number | 'blur' | Debouncer<TValue, TPathKind>,
42) {
43 // If it's already a debounce function, return it as-is.
44 if (typeof debouncer === 'function') {
45 return debouncer;
46 }
47 // If it's 'blur', return a debouncer that never resolves. The field will still be updated when
48 // the control is blurred.
49 if (debouncer === 'blur') {
50 return debounceUntilBlur();
51 }
52 // If it's a non-zero number, return a timer-based debouncer.
53 if (debouncer > 0) {
54 return debounceForDuration(debouncer);
55 }
56 // Otherwise it's 0, so we return a function that will synchronize the model without delay.
57 return immediate;
58}
59
60/**
61 * Creates a debouncer that will wait for the given duration before resolving.

Callers 1

debounceFunction · 0.85

Calls 2

debounceUntilBlurFunction · 0.85
debounceForDurationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…