From b1bfb214ef9af56a0796756498b8ec0053d8e59b Mon Sep 17 00:00:00 2001 From: Alex Rickabaugh Date: Tue, 22 Apr 2025 10:12:10 -0700 Subject: [PATCH] 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 --- packages/common/http/src/resource.ts | 45 ---------------------------- 1 file changed, 45 deletions(-) diff --git a/packages/common/http/src/resource.ts b/packages/common/http/src/resource.ts index 1a2a95ca7c3..ca3544aca42 100644 --- a/packages/common/http/src/resource.ts +++ b/packages/common/http/src/resource.ts @@ -381,48 +381,3 @@ class HttpResourceImpl // This is a type only override of the method declare hasValue: () => this is HttpResourceRef>; } - -/** - * 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 { - readonly status: Signal; - readonly value: WritableSignal; - readonly error: Signal; - readonly isLoading: Signal; - - constructor( - private parent: Resource, - request: Signal, - ) { - 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 { - return this.value() !== undefined; - } - - reload(): boolean { - // TODO: should you be able to reload this way? - return this.parent.reload(); - } -}