Fixed perf issues

This commit is contained in:
TheXamlGuy
2024-07-02 23:38:51 +01:00
parent 929d72e4e8
commit e1ffb541f6
29 changed files with 139 additions and 82 deletions
@@ -0,0 +1,26 @@
using Toolkit.Foundation;
namespace Wallet;
public class ItemCategoryViewModelActivatedHandler(IItemConfigurationCollection configurations,
IServiceFactory serviceFactory,
IPublisher publisher) :
INotificationHandler<ActivationEventArgs<ItemCategoryNavigationViewModel>>
{
public Task Handle(ActivationEventArgs<ItemCategoryNavigationViewModel> args)
{
bool selected = true;
foreach (KeyValuePair<string, Func<ItemConfiguration>> configuration in configurations)
{
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(args => args.Initialize(),
configuration.Key, selected)
is ItemCategoryNavigationViewModel viewModel)
{
publisher.Publish(Create.As(viewModel), nameof(ItemCategoryCollectionViewModel));
selected = false;
}
}
return Task.CompletedTask;
}
}