* Called either directly via `WritableResource.set` or via `.value.set()`.
(value: T)
| 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. |
nothing calls this directly
no test coverage detected