(resource: Resource<T>)
| 668 | * the current resource by throwing the appropriate status code when the value is not available. |
| 669 | */ |
| 670 | export function chain<T>(resource: Resource<T>): T { |
| 671 | switch (resource.status()) { |
| 672 | case 'idle': |
| 673 | throw ResourceParamsStatus.IDLE; |
| 674 | case 'error': |
| 675 | throw new ResourceDependencyError(resource); |
| 676 | case 'loading': |
| 677 | case 'reloading': |
| 678 | throw ResourceParamsStatus.LOADING; |
| 679 | } |
| 680 | return resource.value(); |
| 681 | } |
| 682 | |
| 683 | export const paramsContext: ResourceParamsContext = { |
| 684 | chain, |
no test coverage detected