histoire
Version:
A fast story book powered by Vite
36 lines • 1.81 kB
TypeScript
import type { CollectionEvent } from '../../../server/collect.js';
import type { RuntimeCatalog } from '../../catalog/publication.js';
/** Inputs of the collection barrier. */
export interface CollectionBarrierOptions {
/** Canonical catalog of the generation. */
catalog: Pick<RuntimeCatalog, 'current' | 'updating'> | undefined;
/** Collection observations of the generation. */
onCollection: (handler: (event: CollectionEvent) => void | Promise<void>) => () => void;
/** Called, synchronously and cheaply, for every collection event that matters. */
changed: (event: CollectionEvent) => void;
}
/**
* Tells when source collection is genuinely usable. The catalog's own
* `updating` fence is authoritative (it closes at the first announcement of a
* batch and opens only after its publication, also when nothing changed, which
* no catalog subscription would report); collection events only say when to
* look again. Background revalidation of a restored catalog never closes it.
* The handler never awaits anything, so a collector waiting on it cannot be
* held up by a test run.
* @param options Catalog and collection observations.
* @returns Barrier state and its detach function.
*/
export declare function createCollectionBarrier(options: CollectionBarrierOptions): {
/** A completed catalog exists and no batch owns the source. */
usable: () => boolean;
/** The latest non-background batch failed and no later one completed. */
failed: () => boolean;
/** Message of the failure, when any. */
failure: () => string;
/** A catalog is attached at all. */
attached: () => boolean;
dispose: () => void;
};
/** Barrier type. */
export type CollectionBarrier = ReturnType<typeof createCollectionBarrier>;
//# sourceMappingURL=barrier.d.ts.map