What is the correct way to load data async to be able to show UI as fast as possible to user. For example
I have a xamarin forms projekt, containing a map component. I want to show the map before I get the users current location(from gps) and some locations/pins that are fetched from a server. I have seen these two approaches
1) From constructor call an async method
Map mMyMap;
ctor()
{
InitializeCompeont();
InitAsync();
}
private async void InitAsync()
{
var pins = await GetPinsFromServer();
mMyMap.Pins.Add(pins)
}
2) in On appearing
ctor()
{
InitalizeComponent()
}
protected override async void OnAppearing()
{
var pins = await GetPinsFromServer();
mMyMap.Pins.Add(pins)
}
Both approaces seems to "work", but Im I fooling myself calling the async method from constructor?
Ive also managed to set BindingContext async both ways and it binds correctly
Is there any difference?