export type ConstantAsync = () => Promise; export type Async = (params: I) => Promise; export type LooseApi = Async | ConstantAsync; export interface Pending { kind: 'pending'; promise: Promise; } export interface HasValuePending { kind: 'hasValuePending'; data: O; promise: Promise; } export interface HasValue { kind: 'hasValue'; data: O; } export interface HasError { kind: 'hasError'; error: Error; } export type ResourceState = Pending | HasValuePending | HasValue | HasError; export type Family = Map>; export interface CacheController { (api: Async, params: I): void; (api: ConstantAsync): void; } export interface AwaitableCacheController { (api: Async, params: I): Promise; (api: ConstantAsync): Promise; } export interface ResourceController { pending: boolean; expire: () => void; refresh: () => Promise; }