MCPcopy
hub / github.com/angular/angular / debounceForDuration

Function debounceForDuration

packages/forms/signals/src/api/rules/debounce.ts:63–81  ·  view source on GitHub ↗

* Creates a debouncer that will wait for the given duration before resolving.

(durationInMilliseconds: number)

Source from the content-addressed store, hash-verified

61 * Creates a debouncer that will wait for the given duration before resolving.
62 */
63function debounceForDuration(durationInMilliseconds: number): Debouncer<unknown> {
64 return (_context, abortSignal) => {
65 return new Promise((resolve) => {
66 let timeoutId: ReturnType<typeof setTimeout> | undefined;
67
68 const onAbort = () => {
69 clearTimeout(timeoutId);
70 resolve();
71 };
72
73 timeoutId = setTimeout(() => {
74 abortSignal.removeEventListener('abort', onAbort);
75 resolve();
76 }, durationInMilliseconds);
77
78 abortSignal.addEventListener('abort', onAbort, {once: true});
79 });
80 };
81}
82
83/**
84 * Creates a debouncer that will wait indefinitely, relying on the node to synchronize pending

Callers 1

normalizeDebouncerFunction · 0.85

Calls 4

setTimeoutFunction · 0.85
removeEventListenerMethod · 0.65
addEventListenerMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…