[Refactor] Update commands to use asynchronous patterns with ReactiveCommand

This commit is contained in:
2025-07-07 22:41:08 +01:00
parent ca1708a337
commit 9818a8c416
4 changed files with 43 additions and 40 deletions

View File

@@ -25,6 +25,7 @@
using System;
using System.Reactive;
using System.Threading.Tasks;
using ReactiveUI;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Models;
@@ -61,7 +62,7 @@ public class EditDatViewModel : ViewModelBase
_date = romSet.Date;
_description = romSet.Description;
_homepage = romSet.Homepage;
SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand);
SaveCommand = ReactiveCommand.CreateFromTask(ExecuteSaveCommandAsync);
CancelCommand = ReactiveCommand.Create(ExecuteCloseCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
}
@@ -193,9 +194,9 @@ public class EditDatViewModel : ViewModelBase
void ExecuteCloseCommand() => _view.Close();
async void ExecuteSaveCommand()
async Task ExecuteSaveCommandAsync()
{
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
await using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
RomSet romSetDb = await ctx.RomSets.FindAsync(_romSet.Id);