Search code examples
xamarinmvvmcross

What is the best async loading (view)models strategy when using MVVMCross


I have been working with MVVM for a while (comming from XAML) and I'm using MVVMCross at this moment for a Xamarin project.

What is the best (a good) strategy to load data into the ViewModels\Models in a async way?

PS: I want to prevent long frozen screens when navigating, I'm looking to navigate first and the async load the data.


Solution

  • just to clearify;

    The ViewModels in MVVMCross (MvxViewModel) do have some handy override methods.

    Init for picking up navigation parameters Start to do everything else after the ViewModel is innitualized.

    To load ViewModel data in a more UX friendly way I was happy with the following in my ViewModels

        public override async void Start()
        {
            base.Start();
            myViewModel = await LoadViewModel();
        }
    

    Thanks Thomas and Cheesebaron for the comments