Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        private async Task LoadSuperheroes()
        {
            var superheroes = await _backendService.GetSuperheroes();

            Superheroes.Clear();

            foreach (var hero in superheroes)
            {
                Superheroes.Add(hero);
            }
        }
Ejemplo n.º 3
0
        private void LoadSuperheroes()
        {
            _backendService.GetSuperheroes().Subscribe((superheroes) =>
            {
                Superheroes.Clear();

                foreach (var hero in superheroes)
                {
                    Superheroes.Add(hero);
                }
            });
        }