What's about reworking MaterialDialogs.ShowAlertAsync to make it really awaitable and return Task<bool> instead?
See original GitHub issueHi!
I’ve tried also MaterialDialogs.ShowAlertAsync
which works fine in general.
However, with current implementation I can’t see a way of notifying when the alert (confirmation) box is closed with negative (cancelling) result.
Currently the method is (in general) awaitable, which completes on the confirm popup appearing, however, usually, it doesn’t have much sense from the app logic functionality perspective. From my experience, it’s rather more important to be able further processing of the app logic after the choice been done.
So, I would suggest to rework it to return Task<bool>
, which would complete after the used made his choice.
What do you think? I can also fork and apply that update as well if you have no time for that.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Async gotcha: returning Task.FromResult or ...
Because HandleAsync is actually synchronous, any exception propagates as soon as it's called, not when it's awaited. This is surprising to most ...
Read more >Async method to return true or false in a Task
I know that an async method can only return void or Task . I have read similar methods for Exception handling inside async...
Read more >Async return types (C#)
WaitAndApologizeAsync is awaited by using an await statement instead of an await expression, similar to the calling statement for a synchronous ...
Read more >Is awaiting a Task instead of returning it directly in C# actually ...
Become a Patreon and get source code access: ... async and that's whether you should await a task or when possible returning it...
Read more >What is the best way to return a Task<bool> in a async ...
You can do return Task.FromResult(false) (or you can just make the method async and simply return false).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can also fix that. I set it to 40 since it was the recommended height, but I forgot to consider long titles.
BTW, thanks for raising these issues/suggestions.
Version 1.0.6 has been released, adding
MaterialDialogs.ShowConfirmAsync()
which returnsTask<bool>
. Also, the title of the alert dialog now breaks line when it is long.