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

Method set

packages/core/src/resource/resource.ts:350–382  ·  view source on GitHub ↗

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

(value: T)

Source from the content-addressed store, hash-verified

348 * Called either directly via `WritableResource.set` or via `.value.set()`.
349 */
350 override set(value: T): void {
351 if (this.destroyed) {
352 return;
353 }
354
355 const error = untracked(this.error);
356 const state = untracked(this.state);
357
358 if (!error) {
359 const current = untracked(this.value);
360 if (
361 state.status === 'local' &&
362 (this.equal ? this.equal(current, value) : current === value)
363 ) {
364 return;
365 }
366 }
367
368 // Enter Local state with the user-defined value.
369 this.state.set({
370 extRequest: state.extRequest,
371 status: 'local',
372 previousStatus: 'local',
373 stream: signal(
374 {value},
375 ngDevMode ? createDebugNameObject(this.debugName, 'stream') : undefined,
376 ),
377 });
378
379 // We're departing from whatever state the resource was in previously, so cancel any in-progress
380 // loading operations.
381 this.abortInProgressLoad();
382 }
383
384 override reload(): boolean {
385 // 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