type QueryStateSource = {
  readonly isLoading: boolean;
  readonly error: unknown;
};

export function isAnyLoading(...sources: readonly QueryStateSource[]): boolean {
  return sources.some((source) => source.isLoading);
}

export function getFirstQueryError(...sources: readonly QueryStateSource[]): unknown | null {
  return sources.find((source) => Boolean(source.error))?.error ?? null;
}
