wailsapp / wailsapp/wails

Synchronous Method for Showing `MessageDialog`

Open
#4,792 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement Linux MacOS P2 stale v3 Windows
Dominant language
Go
Stars
36.3k
Forks
1.9k
Avg merge
2d 11h
Merged PRs (30d)
33

Description

Is your feature request related to a problem? Please describe.

Currently, a message dialog usage looks like the code below where the callback per button are asynchronous.

        app.Dialog.Question().
            SetTitle("Migration Warning").
            SetMessage(fmt.Sprintf("%d migrations are available. Do you want to run them now?", len(pending))).
            SetDefaultButton(&application.Button{
                Label: "Run",
                IsCancel: false,
                IsDefault: true,
                Callback: func() {
                    doMigrations()
                },
            }).
            SetCancelButton(&application.Button{
                Label: "Cancel",
                IsCancel: true,
                IsDefault: false,
                Callback: func() {
                    log.Println("Migration cancelled by user.")
                },
            }).
            Show()    

The challenge with this pattern is that, there is no way of returning error or result from each callback function synchronously so that the application can take critical decisions such as exiting the application if a critical request was rejected by the user.

Describe the solution you'd like

I am suggesting a new synchronous method like ShowSync which returns the error and result from either callback function assigned to the buttons.

If feasible, we could also introduce generics so that the result returned from the cancel or default buttons are type safe.

Describe alternatives you've considered

The current implementation in v3 is asynchronous. The v2 implementation was synchronous and similar to the above request. However, the callbacks will be called to return result or error instead simply returning the button labels as the result.

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the current app.Dialog.Question().Show() flow and its button callbacks, then compare it with the synchronous v2 implementation described in the issue. Define how ShowSync should return callback errors and results for default and cancel buttons, including whether a generic API is feasible, and verify both paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.