readiness-manager
Version:
👨💼 Define when your app is ready
39 lines (34 loc) • 856 B
text/typescript
/**
* A status of an action.
*/
export type ActionStatus = 'not_started' | 'pending' | 'resolved' | 'rejected';
/**
* A callback to be executed when an action is ready.
*/
export type ReadyCallback = () => void;
/**
* An action is a single function that needs to be executed to determine if the app is ready.
*/
export type ReadyAction = () => unknown | Promise<unknown>;
/**
* A map of action statuses by their name.
*/
export type ActionsStatus = {
[key in ActionStatus]?: string[];
};
/**
* A beacon is a single action that needs to be executed to determine if the app is ready.
*/
export interface Beacon {
name: string;
action: ReadyAction;
status: ActionStatus;
callbacks: ReadyCallback[];
debug?: boolean;
}
/**
* A map of beacons by their name.
*/
export interface BeaconsMap {
[name: string]: Beacon;
}