C#C
C#3y ago
kurumi

✅ async .NET MAUI binding

Hello, on Xamarin channel I found this code how to update UI with threads and async stuff.
https://youtu.be/-LY4ATA8Bgw?si=cRmPMFNjL9-zTxui&t=1212
But in .NET MAUI it says Warning CS0618 'Device.BeginInvokeOnMainThread(Action)' is obsolete: 'Use BindableObject.Dispatcher.Dispatch() instead'. So how can I bind some async data from my API by using it?
Leave an example please 😄
using CommunityToolkit.Mvvm.ComponentModel;
using MRSUMobile.MVVM.Model;
using MRSUMobile.Services;

namespace MRSUMobile.MVVM.ViewModel
{
    public partial class AppShellViewModel : ObservableObject
    {
        IMrsuApiService mrsuApi;

        [ObservableProperty]
        User user = new User();

        public AppShellViewModel(IMrsuApiService mrsuApiService)
        {
            mrsuApi = mrsuApiService;

            // async binding of user ?
            // user = await mrsuApi.GetMyProfile();
        }
    }
}
Was this page helpful?