MCPcopy Create free account
hub / github.com/angular/angular / normalizeDebouncer

Function normalizeDebouncer

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

Source from the content-addressed store, hash-verified

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