Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    A common framework for displaying notifications to the client. Submitted notifications are added to a queue, and up to Notifications.MAX_ACTIVE notifications are displayed at once. Each notification is displayed for Notifications.LIFETIME_MS milliseconds before being removed, at which point further notifications are pulled from the queue.

    ui.notifications.error("This is a permanent error message", {permanent: true});
    ui.notifications.warn("LOCALIZED.WARNING.MESSAGE", {localize: true});
    ui.notifications.success("This is a success message, not logged to the console", {console: false});
    ui.notifications.info("LOCALIZED.FORMAT.STRING", {format: {key1: "foo", key2: "bar"}});
    const progress = ui.notifications.info("Thing Happening!", {progress: true});
    progress.update({pct: 0.25, message: "Still happening!"});
    progress.update({pct: 0.50, message: "Almost there!"});
    progress.update({pct: 0.75, message: "Stay on target!"});
    progress.update({pct: 1.0, message: "Done!"});
    Index

    Properties

    LIFETIME_MS: number = 5000

    Notification lifetime in milliseconds.

    MAX_ACTIVE: number = 5

    The maximum number of active notifications.

    Methods

    • Clear all notifications.

      Returns void

    • Display a notification with the "error" type.

      Parameters

      • message: string | object

        The content of the error message

      • Optionaloptions: NotificationOptions

        Notification options passed to the notify function

      Returns Readonly<Notification>

      The registered notification

      notify

    • Does the notification linked to the ID exist?.

      Parameters

      • notification: number | Notification

        The Notification or ID to remove

      Returns boolean

    • Display a notification with the "info" type.

      Parameters

      • message: string | object

        The content of the info message

      • Optionaloptions: NotificationOptions

        Notification options passed to the notify function

      Returns Readonly<Notification>

      The registered notification

      notify

    • Push a new notification into the queue

      Parameters

      • message: string | object

        The content of the notification message. A passed object should have a meaningful override of the toString method. If the object is an Error and console logging is requested, the stack trace will be included.

      • type: string = "info"

        The type of notification, "info", "warning", and "error" are supported

      • Optionaloptions: NotificationOptions = {}

        Additional options which affect the notification

      Returns Notification

      The registered notification

    • Remove the notification linked to the ID.

      Parameters

      • notification: number | Notification

        The Notification or ID to remove

      Returns void

    • Display a notification with the "success" type.

      Parameters

      • message: string | object

        The content of the success message

      • Optionaloptions: NotificationOptions

        Notification options passed to the notify function

      Returns Readonly<Notification>

      The registered notification

      notify

    • Update the progress of the notification.

      Parameters

      • notification: number | Notification

        A Notification or ID to update

      • Optionalupdate: {
            clean?: string;
            escape?: string;
            format?: Record<string, string>;
            localize?: string;
            message?: string;
            pct?: number;
        }

        An incremental progress update

        • Optionalclean?: string
        • Optionalescape?: string
        • Optionalformat?: Record<string, string>

          A mapping of formatting strings passed to Localization#format

        • Optionallocalize?: string

          Localize updates to presented progress text

        • Optionalmessage?: string

          An update to the string message

        • Optionalpct?: number

          An update to the completion percentage

      Returns void

    • Display a notification with the "warning" type.

      Parameters

      • message: string | object

        The content of the warning message

      • Optionaloptions: NotificationOptions

        Notification options passed to the notify function

      Returns Readonly<Notification>

      The registered notification

      notify