-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Calling async method on ViewModel.Initialize never ends and InitializeTask properties never got updated #2829
Comments
A couple of things:
|
Why isn't the workaround implemented by default in MvvmCross? Not being able to do long asynchronous operations on the
|
@ernestoyaquello See the linked PR for what I'm thinking for v6.1. However, please note that you should really make use of a splash screen if you're going to be doing heavy lifting prior to the main view of your application. |
And what about iOs? how do you suggest to use splash screen on iOs? Do you mean the basic Launch Screen or a dump View / Page that its viewModel navigates to the real first viewModel? To avoid the launch time limitation on iOS I used to use a trick i've learnt from an old Xamarin developed app, on appDelegate , method FinishedLaunching just: Thanks for all your time and info! i really appreciate it! and thanks for your awesome work! |
@nickrandolph, I understand that extremely heavy loading in the first viewmodel can cause problems, but, in my opinion, a mere warning about it in the documentation would have been better than not allowing data loading at all - speaking of which, neither this new synchronous implementation nor the workarounds to make it asynchronous again can be found in the official documentation (or at least I cannot find them?), which is odd considering that this new, app-breaking behaviour is supposed to be by design. On the other hand, we are already using a splash screen, but I guess that you suggest we use the first viewmodel as a splash screen? |
@ernestoyaquello you expect too much from the documentation. This is an open source project made by a couple of people in the spare time. What do you prefer, good documentation or fitness of code? Pick one, not both. |
@Cheesebaron I am grateful for the altruistic efforts that go into this project, but I expected to be able to load data in my first viewmodel as usual in the way that the documentation tells me to, and I think this is the right place to discuss about it. I understand that the ability to load data asynchronously in the first viewmodel might be problematic in some cases, but removing this feature completely is even more problematic in my opinion (plenty of apps will stop working), specially when there is no documentation about it and the workaround is hidden in someone's personal blog. |
I encountered the same problem. It is reasonable to place the sync codes in the Initialize method - if it works fine as it is designed. Getting the data from REST APIs is not always a heavy task for most cases. Update: I have solved this problem following @nickrandolph 's post. Thanks. |
Steps to reproduce 📜
Create a ViewModel and override Initialize (this only happens if the first ViewModel is calling async code in Initialize method)
Call an async / await method (eg: refit service call)
Expected behavior 🤔
The execution flow should continue after awaited method complete its execution. This is working on MVVMCross 5.7
Actual behavior 🐛
The device screen is black and never continue to the next line of code (eg: converting result to other model)
Configuration 🔧
VS 2017 15.6.6
Version: MvvmCross 6 using Xamarin.Forms 2.5.1.444934
Platform:
The text was updated successfully, but these errors were encountered: