WIP: Item counts

This commit is contained in:
TheXamlGuy
2024-06-11 22:32:14 +01:00
parent 0fecdef1fe
commit ec7d6611a1
28 changed files with 205 additions and 74 deletions
+22
View File
@@ -0,0 +1,22 @@
using Toolkit.Foundation;
namespace Wallet;
public class ItemChangedHandler(IMediator mediator,
IPublisher publisher) :
INotificationHandler<ChangedEventArgs<Item<(Guid, string)>>>
{
public async Task Handle(ChangedEventArgs<Item<(Guid, string)>> args)
{
IReadOnlyCollection<(string, int)>? categoryCounts = await mediator.Handle<CountEventArgs<ItemCategory>,
IReadOnlyCollection<(string, int)>>(Count.As<ItemCategory>());
if (categoryCounts is { Count: > 0 } )
{
foreach ((string key, int count) in categoryCounts)
{
publisher.Publish(Notify.As(new Item<int>(count)), key);
}
}
}
}