Where should data be loaded into the ViewModel

I am using Xamarin.Forms and want to call an async method for loading data into the view model.

How should I load data (asynchronously) into the view model?

I tried to do it in the constructor but I can’t call async method in the constructor.

this is my code:

public List<IdeaResource> IdeasList;
public IdeasViewModel()
{
    HypermediaClient client = new HypermediaClient();
    IdeasList = await client.GetIdeasAsync();
}

While definitely not a best practice there is a work around. Create an event and call the event from the constructor.

The work around is that the event handler can be async and calling the event wont block the UI thread.

public class IdeasViewModel : ViewModelBase {
    public List<IdeaResource> IdeasList;
    public IdeasViewModel() {
        Initialized += OnInitialized;
        Initialized(this, EventArgs.Empty);
    }

    private event EventHandler Initialized = delegate { };

    private async void OnInitialized(object sender, EventArgs e) {
        //unsubscribing from the event
        Initialized += OnInitialized;
        //call async 
        var client = new HypermediaClient();
        IdeasList = await client.GetIdeasAsync();   
    }
}

Ideally the data load functionality should be in a publicly available method

public async Task LoadDataAsync() {
    var client = new HypermediaClient();
    IdeasList = await client.GetIdeasAsync();  
}

and called in an event handler in the view.

public class IdeasPage : ContentPage {
    private IdeasViewModel viewModel;

    public IdeasPage() {
        //...assign variables
    }

    protected override void OnAppearing() {
        this.Appearing += Page_Appearing;
    }

    private async void Page_Appearing(object sender, EventArgs e) {
        //...call async code here
        await viewModel.LoadDataAsync();

        //unsubscribing from the event
        this.Appearing -= Page_Appearing;
    }
}