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

Method set

packages/core/src/resource/resource.ts:369–401  ·  view source on GitHub ↗

* Called either directly via `WritableResource.set` or via `.value.set()`.

(value: T)

Source from the content-addressed store, hash-verified

367 * Called either directly via `WritableResource.set` or via `.value.set()`.
368 */
369 override set(value: T): void {
370 if (this.destroyed) {
371 return;
372 }
373
374 const error = untracked(this.error);
375 const state = untracked(this.state);
376
377 if (!error) {
378 const current = untracked(this.value);
379 if (
380 state.status === 'local' &&
381 (this.equal ? this.equal(current, value) : current === value)
382 ) {
383 return;
384 }
385 }
386
387 // Enter Local state with the user-defined value.
388 this.state.set({
389 extRequest: state.extRequest,
390 status: 'local',
391 previousStatus: 'local',
392 stream: signal(
393 {value},
394 ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,
395 ),
396 });
397
398 // We're departing from whatever state the resource was in previously, so cancel any in-progress
399 // loading operations.
400 this.abortInProgressLoad();
401 }
402
403 override reload(): boolean {
404 // We don't want to restart in-progress loads.

Callers

nothing calls this directly

Calls 5

abortInProgressLoadMethod · 0.95
untrackedFunction · 0.90
signalFunction · 0.90
createDebugNameObjectFunction · 0.70
setMethod · 0.65

Tested by

no test coverage detected