예제 #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;
            }
        }
예제 #2
0
        private async Task LoadSuperheroes()
        {
            var superheroes = await _backendService.GetSuperheroes();

            Superheroes.Clear();

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

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