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

Method controlValueSignal

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

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

()

Source from the content-addressed store, hash-verified

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