Interface IDialogWrapper

A simple interface for dialog wrappers that can be used to abstract away the browser's built-in dialog methods or custom implementations.

interface IDialogWrapper {
    alert: (message?: string) => Promise<void>;
    choose?: (
        message?: string,
        options?: IDialogChooseOption[],
    ) => Promise<null | string>;
    confirm: (message?: string) => Promise<boolean>;
    confirmSync: (message?: string) => boolean;
    prompt: (
        message?: string,
        _default?: string,
        cancel?: boolean,
    ) => Promise<null | string>;
}

Properties

alert: (message?: string) => Promise<void>
choose?: (
    message?: string,
    options?: IDialogChooseOption[],
) => Promise<null | string>

Multi-button dialog. Resolves with the clicked option's id, or null if the user dismisses it with Escape. The first option flagged primary: true (or the first option, when none is flagged) is the default action and is bound to Enter. Optional, so existing implementations of this interface stay valid.

confirm: (message?: string) => Promise<boolean>
confirmSync: (message?: string) => boolean
prompt: (
    message?: string,
    _default?: string,
    cancel?: boolean,
) => Promise<null | string>