public async Task GetSuperheroes() { IsLoading = true; try { var superheroesJson = await _customHttpClient.GetStringAsync("superhero"); var superheroes = JsonConvert.DeserializeObject <Superhero[]>(superheroesJson); Superheroes.Clear(); foreach (var hero in superheroes) { Superheroes.Add(hero); } } catch (HttpRequestException ex) when(ex.Message.Contains("304")) { // Intentionally left blank, 304 response is fine } finally { IsLoading = false; } }
private async Task LoadSuperheroes() { var superheroes = await _backendService.GetSuperheroes(); Superheroes.Clear(); foreach (var hero in superheroes) { Superheroes.Add(hero); } }
private void LoadSuperheroes() { _backendService.GetSuperheroes().Subscribe((superheroes) => { Superheroes.Clear(); foreach (var hero in superheroes) { Superheroes.Add(hero); } }); }