Skip to content

Commit 681d20b

Browse files
Rename GetDataFromAPI
1 parent 75a7f9e commit 681d20b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

sample/HackerNews/ViewModels/Base/BaseViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected void SetProperty<T>(ref T backingStore, in T value, in Action? onChang
4141
OnPropertyChanged(propertyName);
4242
}
4343

44-
protected async Task<TDataObject> GetDataObjectFromAPI<TDataObject>(string apiUrl)
44+
protected async Task<TDataObject> GetDataFromAPI<TDataObject>(string apiUrl)
4545
{
4646
await UpdateActivityIndicatorStatus(true).ConfigureAwait(false);
4747

sample/HackerNews/ViewModels/NewsViewModel_BadAsyncAwaitPractices.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Linq;
55
using System.Threading.Tasks;
6+
using AsyncAwaitBestPractices;
67
using System.Windows.Input;
78
using HackerNews.Shared;
89
using Xamarin.Forms;
@@ -76,15 +77,15 @@ async Task<List<StoryModel>> GetTopStories(int numberOfStories)
7677
//ToDo Refactor
7778
async Task<StoryModel> GetStory(string storyId)
7879
{
79-
return await GetDataObjectFromAPI<StoryModel>($"https://hacker-news.firebaseio.com/v0/item/{storyId}.json?print=pretty");
80+
return await GetDataFromAPI<StoryModel>($"https://hacker-news.firebaseio.com/v0/item/{storyId}.json?print=pretty");
8081
}
8182

8283
//ToDo Refactor
8384
async Task<List<string>?> GetTopStoryIDs()
8485
{
8586
try
8687
{
87-
return await GetDataObjectFromAPI<List<string>>("https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty");
88+
return await GetDataFromAPI<List<string>?>("https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty");
8889
}
8990
catch (Exception e)
9091
{

0 commit comments

Comments
 (0)