MCPcopy Index your code
hub / github.com/angular/angular / controlValueSignal

Method controlValueSignal

packages/forms/signals/src/field/node.ts:381–402  ·  view source on GitHub ↗

* Creates a linked signal that initiates a debounceSync when set.

()

Source from the content-addressed store, hash-verified

379 * Creates a linked signal that initiates a {@link debounceSync} when set.
380 */
381 private controlValueSignal(): ControlValueSignal<unknown> {
382 const controlValue = linkedSignal(this.value) as ControlValueSignal<unknown>;
383
384 controlValue.rawSet = controlValue.set;
385 controlValue.set = (newValue) => {
386 // We intentionally allow same-value updates here to ensure that setting the control value
387 // (even to the same value) still marks the control as dirty.
388 controlValue.rawSet(newValue);
389 this.markAsDirty();
390 this.debounceSync();
391 };
392 const rawUpdate = controlValue.update;
393 controlValue.update = (updateFn) => {
394 // We intentionally allow same-value updates here to ensure that updating the control value
395 // (even to the same value) still marks the control as dirty.
396 rawUpdate(updateFn);
397 this.markAsDirty();
398 this.debounceSync();
399 };
400
401 return controlValue;
402 }
403
404 /**
405 * Synchronizes the {@link controlValue} with the {@link value} signal immediately.

Callers 1

constructorMethod · 0.95

Calls 4

markAsDirtyMethod · 0.95
debounceSyncMethod · 0.95
linkedSignalFunction · 0.90
rawSetMethod · 0.80

Tested by

no test coverage detected