refactor(core): remove resource flag.

This was used to migrate G3 and is no longer necessary.

(cherry picked from commit d1ab73dd87)
This commit is contained in:
Matthieu Riegler 2025-11-01 17:22:01 +01:00 committed by Jessica Janiuk
parent ba28305b04
commit a02b957b60

View file

@ -30,13 +30,6 @@ import {PendingTasks} from '../pending_tasks';
import {linkedSignal} from '../render3/reactivity/linked_signal';
import {DestroyRef} from '../linker/destroy_ref';
/**
* Whether a `Resource.value()` should throw an error when the resource is in the error state.
*
* This internal flag is being used to gradually roll out this behavior.
*/
let RESOURCE_VALUE_THROWS_ERRORS_DEFAULT = true;
/**
* Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
* a loader function, which exposes the result of the loading operation via signals.
@ -77,7 +70,6 @@ export function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T |
options.defaultValue,
options.equal ? wrapEqualityFn(options.equal) : undefined,
options.injector ?? inject(Injector),
RESOURCE_VALUE_THROWS_ERRORS_DEFAULT,
);
}
@ -177,7 +169,6 @@ export class ResourceImpl<T, R> extends BaseWritableResource<T> implements Resou
defaultValue: T,
private readonly equal: ValueEqualityFn<T> | undefined,
injector: Injector,
throwErrorsFromValue: boolean = RESOURCE_VALUE_THROWS_ERRORS_DEFAULT,
) {
super(
// Feed a computed signal for the value to `BaseWritableResource`, which will upgrade it to a
@ -196,11 +187,7 @@ export class ResourceImpl<T, R> extends BaseWritableResource<T> implements Resou
}
if (!isResolved(streamValue)) {
if (throwErrorsFromValue) {
throw new ResourceValueError(this.error()!);
} else {
return defaultValue;
}
throw new ResourceValueError(this.error()!);
}
return streamValue.value;