Skip to content

Commit 9a590bf

Browse files
Kunal22shahdr1rrb
andauthored
chore: resolving PR comments
Co-authored-by: David <[email protected]>
1 parent 4f27836 commit 9a590bf

File tree

5 files changed

+12
-34
lines changed

5 files changed

+12
-34
lines changed

UI/MVUX/src/MVUX/Presentation/FeedSample/FeedModel.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,18 @@ namespace MVUX.Presentation.FeedSample;
44

55
public partial record FeedModel
66
{
7-
public IFeed<Person> Person { get; }
8-
9-
public FeedModel()
10-
{
11-
Person = Feed.Async(async ct =>
12-
{
13-
await Task.Delay(2000, ct);
14-
15-
var people = new[]
7+
private static readonly Person[] _people = new[]
168
{
179
new Person("Master", "Yoda"),
1810
new Person("Darth", "Vader"),
1911
new Person("Luke", "Skywalker")
2012
};
21-
22-
return people[new Random().Next(people.Length)];
13+
14+
public IFeed<Person> Person => Feed.Async(async ct =>
15+
{
16+
await Task.Delay(2000, ct); // Simulate network delay
17+
18+
return _people[Random.Shared.Next(people.Length)];
2319
});
2420
}
2521

UI/MVUX/src/MVUX/Presentation/FeedViewCommandSample/FeedViewCommandModel.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,17 @@ namespace MVUX.Presentation.FeedViewCommandSample;
22

33
public partial class FeedViewCommandModel
44
{
5-
public IListState<Item> Items => ListState.Value(this, () =>
6-
{
7-
return ImmutableList.Create(
5+
public IListState<Item> Items => ListState.Value(this, () => ImmutableList.Create(
86
new Item { Text = "Item 1" },
97
new Item { Text = "Item 2" },
108
new Item { Text = "Item 3" }
11-
);
12-
});
9+
));
1310

1411
public async ValueTask RemoveItem(Item item)
1512
{
1613
if (item != null)
1714
{
18-
await Items.UpdateAsync(currentItems =>
19-
{
20-
var updatedItems = currentItems.Remove(item);
21-
return updatedItems;
22-
});
15+
await Items.UpdateAsync(currentItems => currentItems.Remove(item));
2316
}
2417
}
2518
}

UI/MVUX/src/MVUX/Presentation/IMessengerSample/PeopleService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ namespace MVUX.Presentation.IMessengerSample;
44

55
public partial record Person(int Id, string FirstName, string LastName)
66
{
7-
public static Person EmptyPerson() =>
8-
new Person(Id: default, FirstName: string.Empty, LastName: string.Empty);
7+
public static Person Empty { get; } = new Person(Id: default, FirstName: string.Empty, LastName: string.Empty);
98
}
109

1110
public interface IPeopleService

UI/MVUX/src/MVUX/Presentation/ListFeedSample/ListFeedModel.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,4 @@ public partial record ListFeedModel
1111
new Person("Luke", "Skywalker")
1212
);
1313
});
14-
public ListFeedModel()
15-
{
16-
}
1714
}

UI/MVUX/src/MVUX/Presentation/RefreshListFeed/RefreshSignalModel.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ public partial record RefreshSignalModel
55
private readonly Signal _refreshList = new();
66
private int _updateCounter = 0;
77

8-
public RefreshSignalModel()
9-
{
10-
}
11-
128
public IListFeed<string> SimpleList => ListFeed.Async(GetStringsAsync, _refreshList);
139

1410
public async ValueTask<IImmutableList<string>> GetStringsAsync(CancellationToken ct)
@@ -25,9 +21,6 @@ public async ValueTask<IImmutableList<string>> GetStringsAsync(CancellationToken
2521
}
2622

2723
public async ValueTask RefreshList()
28-
{
29-
_refreshList.Raise();
30-
await Task.Delay(1000);
31-
}
24+
=> _refreshList.Raise();
3225
}
3326
}

0 commit comments

Comments
 (0)