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

Method set

packages/core/src/resource/resource.ts:351–383  ·  view source on GitHub ↗

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

(value: T)

Source from the content-addressed store, hash-verified

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