Files
quality_analyse/web/src/importLifecycleGuards.ts
T

18 lines
683 B
TypeScript

export function importIssuePageKey(runId: string, page: number): string {
return `${runId}:${page}`;
}
export function matchesImportIssuePage(loadedRunId: string, loadedPage: number, runId: string, page: number): boolean {
return loadedRunId === runId && loadedPage === page;
}
export async function runImportPollFollowup<T>(
runId: string,
isCurrent: (runId: string) => boolean,
followup: () => Promise<T>,
): Promise<{ started: false; current: false } | { started: true; current: boolean; value: T }> {
if (!isCurrent(runId)) return { started: false, current: false };
const value = await followup();
return { started: true, current: isCurrent(runId), value };
}