Skip to content

Commit b1bfb21

Browse files
alxhubmmalerba
authored andcommitted
refactor(common): delete unused code for HttpResource (angular#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 angular#60919
1 parent 57794f0 commit b1bfb21

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

packages/common/http/src/resource.ts

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -381,48 +381,3 @@ class HttpResourceImpl<T>
381381
// This is a type only override of the method
382382
declare hasValue: () => this is HttpResourceRef<Exclude<T, undefined>>;
383383
}
384-
385-
/**
386-
* A `Resource` of the `HttpResponse` meant for use in `HttpResource` if we decide to go this route.
387-
*
388-
* TODO(alxhub): delete this if we decide we don't want it.
389-
*/
390-
class HttpResponseResource implements Resource<HttpResponseBase | undefined> {
391-
readonly status: Signal<ResourceStatus>;
392-
readonly value: WritableSignal<HttpResponseBase | undefined>;
393-
readonly error: Signal<unknown>;
394-
readonly isLoading: Signal<boolean>;
395-
396-
constructor(
397-
private parent: Resource<unknown>,
398-
request: Signal<unknown>,
399-
) {
400-
this.status = computed(() => {
401-
// There are two kinds of errors which can occur in an HTTP request: HTTP errors or normal JS
402-
// errors. Since we have a response for HTTP errors, we report `Resolved` status even if the
403-
// overall request is considered to be in an Error state.
404-
if (parent.status() === ResourceStatus.Error) {
405-
return this.value() !== undefined ? ResourceStatus.Resolved : ResourceStatus.Error;
406-
}
407-
return parent.status();
408-
});
409-
this.error = computed(() => {
410-
// Filter out HTTP errors.
411-
return this.value() === undefined ? parent.error() : undefined;
412-
});
413-
this.value = linkedSignal({
414-
source: request,
415-
computation: () => undefined as HttpResponseBase | undefined,
416-
});
417-
this.isLoading = parent.isLoading;
418-
}
419-
420-
hasValue(): this is Resource<HttpResponseBase> {
421-
return this.value() !== undefined;
422-
}
423-
424-
reload(): boolean {
425-
// TODO: should you be able to reload this way?
426-
return this.parent.reload();
427-
}
428-
}

0 commit comments

Comments
 (0)