Files
frontend/src/services/ui/promptService.ts

26 lines
574 B
TypeScript
Raw Normal View History

export type PromptType = 'info' | 'success' | 'warning' | 'error';
export interface PromptPayload {
title?: string;
message: string;
type?: PromptType;
duration?: number;
}
type PromptListener = (payload: PromptPayload) => void;
let promptListener: PromptListener | null = null;
export const bindPromptListener = (listener: PromptListener) => {
promptListener = listener;
return () => {
if (promptListener === listener) {
promptListener = null;
}
};
};
export const showPrompt = (payload: PromptPayload) => {
promptListener?.(payload);
};