MCPcopy Create free account
hub / github.com/angular/angular / projectStatusOfState

Function projectStatusOfState

packages/core/src/resource/resource.ts:608–617  ·  view source on GitHub ↗

* Project from a state with `ResourceInternalStatus` to the user-facing `ResourceStatus`

(state: ResourceState<unknown>)

Source from the content-addressed store, hash-verified

606 * Project from a state with `ResourceInternalStatus` to the user-facing `ResourceStatus`
607 */
608function projectStatusOfState(state: ResourceState<unknown>): ResourceStatus {
609 switch (state.status) {
610 case 'loading':
611 return state.extRequest.reload === 0 ? 'loading' : 'reloading';
612 case 'resolved':
613 return isResolved(state.stream!()) ? 'resolved' : 'error';
614 default:
615 return state.status;
616 }
617}
618
619function isResolved<T>(state: ResourceStreamItem<T>): state is {value: T} {
620 return (state as {error: unknown}).error === undefined;

Callers 1

constructorMethod · 0.85

Calls 1

isResolvedFunction · 0.85

Tested by

no test coverage detected