refactor(common): delete unused code for HttpResource (#60919)

Remove the code related to exposing the response of an HTTP request as a
`Resource` itself, as the final API will not go in this direction.

PR Close #60919
This commit is contained in:
Alex Rickabaugh 2025-04-22 10:12:10 -07:00 committed by Miles Malerba
parent 57794f0256
commit b1bfb214ef

View file

@ -381,48 +381,3 @@ class HttpResourceImpl<T>
// This is a type only override of the method
declare hasValue: () => this is HttpResourceRef<Exclude<T, undefined>>;
}
/**
* A `Resource` of the `HttpResponse` meant for use in `HttpResource` if we decide to go this route.
*
* TODO(alxhub): delete this if we decide we don't want it.
*/
class HttpResponseResource implements Resource<HttpResponseBase | undefined> {
readonly status: Signal<ResourceStatus>;
readonly value: WritableSignal<HttpResponseBase | undefined>;
readonly error: Signal<unknown>;
readonly isLoading: Signal<boolean>;
constructor(
private parent: Resource<unknown>,
request: Signal<unknown>,
) {
this.status = computed(() => {
// There are two kinds of errors which can occur in an HTTP request: HTTP errors or normal JS
// errors. Since we have a response for HTTP errors, we report `Resolved` status even if the
// overall request is considered to be in an Error state.
if (parent.status() === ResourceStatus.Error) {
return this.value() !== undefined ? ResourceStatus.Resolved : ResourceStatus.Error;
}
return parent.status();
});
this.error = computed(() => {
// Filter out HTTP errors.
return this.value() === undefined ? parent.error() : undefined;
});
this.value = linkedSignal({
source: request,
computation: () => undefined as HttpResponseBase | undefined,
});
this.isLoading = parent.isLoading;
}
hasValue(): this is Resource<HttpResponseBase> {
return this.value() !== undefined;
}
reload(): boolean {
// TODO: should you be able to reload this way?
return this.parent.reload();
}
}