await ModalService.CreateModalAsync doesn't wait for modal to be closed
See original GitHub issueHi next code doesn’t wait for modal to be closed, Console.WriteLine is executed as the modal is shown
modalRef = await ModalService.CreateModalAsync<MyComponent, DlgResult>(modalConfig, templateOptions);
Console.WriteLine("after");
tried ModalService.CreateConfirmAsync but the same is there any alternative? thanks
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
javascript - await bootstrap modal close by user
I want to prevent the code until the user has pressed the OK button on it. I tried async/await like this below, which...
Read more >Async call on Close · Issue #53 · Blazored/Modal
I was able to solve this. private async void ModalClosed(ModalResult modalResult) { if (!modalResult.Cancelled) { UsersList = await UsersApi.
Read more >javascript - await does not wait for Promise to finish
So it's a bit weird. The "waiting" happens within that aync function, not your initial js function. consider this example
Read more >await operator - asynchronously wait for a task to complete
The await operator suspends evaluation of the enclosing async method until the asynchronous operation represented by its operand completes.
Read more >await - JavaScript - MDN Web Docs - Mozilla
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async...
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
Yes, you can create a custom proxy for ModalService as follow:
1. define a proxy service for ModalService
2. Injection service ModalServiceWrapper
3. Replacing the ModalService with the ModalServiceWrapper
aside: MyComponent.razor
MyOptions
Hi, @mrjohnr I’m sorry for my poor English, it’s possible to get result after modal closes using await, but there is no such consideration for the time being.
In my last reply, I said in the future that you can get results in OnOk’s callback or OnCancel’s callback function, it may appear in version 0.8 or version 0.7.4.
Now you can use the callback function of AfterClose. I’m Sorry for the bad development experience.