* Project from a state with `ResourceInternalStatus` to the user-facing `ResourceStatus`
(state: ResourceState<unknown>)
| 572 | * Project from a state with `ResourceInternalStatus` to the user-facing `ResourceStatus` |
| 573 | */ |
| 574 | function projectStatusOfState(state: ResourceState<unknown>): ResourceStatus { |
| 575 | switch (state.status) { |
| 576 | case 'loading': |
| 577 | return state.extRequest.reload === 0 ? 'loading' : 'reloading'; |
| 578 | case 'resolved': |
| 579 | return isResolved(state.stream!()) ? 'resolved' : 'error'; |
| 580 | default: |
| 581 | return state.status; |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | function isResolved<T>(state: ResourceStreamItem<T>): state is {value: T} { |
| 586 | return (state as {error: unknown}).error === undefined; |
no test coverage detected
searching dependent graphs…