-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Support IInitialize with Dialog ViewModel #3223
Comments
Please explain what the benefit / scenario is that you hope to solve here? I'm assuming you are used to Forms/MAUI Page Navigation hence the request. Dialogs and Page Navigation work differently. There is in fact no actual need for an "Initialize" interface.
|
Thanks for the feedback, @dansiegel. I understand the distinction between Dialogs and Page Navigation, but my suggestion is focused on supporting asynchronous initialization. The current Introducing Alternatively, reusing the |
There is a major drawback to an async interface when showing a dialog. If you make a call to a service or perform some other async operation, the Dialog will not show until that operation is completed, which can cause some very bad user experiences. Imagine clicking a button to show a dialog, but first a network call is made before the dialog is shown, there will be a noticeable delay from when the button was pushed to when the dialog was shown. Of course, the first instinct will be to blame Prism, when in actuality it's the async nature of the code. We had this exact same problem when we provided support for the IInitializeAsync for navigation. Suddenly everyone's navigation started to lag and feeling "slow". Of course, Prism got the blame but turns out it was their code in the Async interface that was causing the issues because the navigation couldn't complete until their async code finished. Why do you want to have the dialog wait on a task before opening? Why not show the dialog immediately and show a loading indicator when making any async calls you need. This way your UI stays very responsive. |
Thanks for the explanation. I understand the concern about delays with async dialogs, but since In my case, the async task is brief, and I currently have to use |
Trying to have consistency with patterns that are not recommended, and can actually be a trap, isn't a good reason to add a new API. What is your main concern with |
I totally agree, but then if the
As mentioned, the Task I execute is very short, some milliseconds. So there is no noticeable delay on the user experience. In this case, it's better to load it before the view is displayed, that avoid a re-render in a very short time that can produce blinks in the view. And yes, if we can avoid the |
Yes, async void is a perfectly valid paradigm. It's used in events and commands. I didn't even want to add the To be clear, I'm not against adding it, I'm just having a hard time being convinced it should be added. Are you by chance a Commercial Plus license holder? |
Yes |
I can't find your account. Connect with us on our Discord to discuss. |
Summary
In addition of the
IDialogAware
, provide a Dialog ViewModel initialization, similar ofIInitialize
andIInitializeAsync
of page navigation.API Changes
Add the equivalent of
IInitialize & IInitializeAsync
interfaces for the Dialogs.Intended Use Case
Support the synchronous and asynchronous initialization of a Dialog ViewModel.
The text was updated successfully, but these errors were encountered: