Skip to content

Enhanced Configuration for toast.promise States #464

@bakikucukcakiroglu

Description

@bakikucukcakiroglu

Feature Request: Enhanced Configuration for toast.promise States

Problem Statement:
Currently, toast.promise supports basic customization of messages for different states (loading, success, error), but lacks support for detailed configurations like different actions and descriptions for each state. If a user tries to add a custom component to implement description and buttons, they lose the consistent styling provided by the library(also code becomes cumbersome).

Using data and error parameters to show a toast description, supplying an action based on the result of the promise would be really elegant. You can make user go to the output's page on success while open logs on error.

Note: Please let me know if there is an easy way of doing that but I'm missing.

Example Usage:

toast.promise(
    new Promise((resolve, reject) => {
        setTimeout(() => {
            if (Math.random() > 0.2) {
                resolve("Transcription successful");
            } else {
                reject("Transcription failed");
            }
        }, 1000);
    }), {
        loading: {
           "Loading", {
               description: "Please wait for a few seconds..."
            }
        },
        success: {
            "Transcription successful", {
            description: "Your transcription has been completed successfully.",
               action: {
                   label: "View transcription",
                   onClick: () => {
                       console.log("View transcription");
                   }
               }
           }
        },
        error: {
            "Transcription failed", {
               description: "Unable to complete your transcription at this time."
            }
        }
    }
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions