From dbf590ace8dba734cbd3725382a682eda3ce475b Mon Sep 17 00:00:00 2001 From: Michael Stonis Date: Fri, 6 Dec 2024 15:54:36 -0600 Subject: [PATCH] Refactor command execution handling - Updated subscription logic for command execution. - Improved async handling in subscription methods. --- src/R3/ReactiveCommand.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/R3/ReactiveCommand.cs b/src/R3/ReactiveCommand.cs index 6177019..4be2fdf 100644 --- a/src/R3/ReactiveCommand.cs +++ b/src/R3/ReactiveCommand.cs @@ -27,14 +27,14 @@ public ReactiveCommand(Action execute) { this.list = new FreeListCore(this); this.canExecute = true; - this.subscription = this.Subscribe((Command: this, Action: execute), static (value, state) => state.Command.HandleExecution(value, state.Action)); + this.subscription = this.Subscribe((HandleExecutionAction: (Action>)HandleExecution, Action: execute), static (value, state) => state.HandleExecutionAction(value, state.Action)); } public ReactiveCommand(Func executeAsync, AwaitOperation awaitOperation = AwaitOperation.Sequential, bool configureAwait = true, bool cancelOnCompleted = false, int maxSequential = -1) { this.list = new FreeListCore(this); this.canExecute = true; - this.subscription = this.SubscribeAwait((Command: this, Func: executeAsync), static (value, state, cancellationToken) => state.Command.HandleAsyncExecution(value, state.Func, cancellationToken), awaitOperation, configureAwait, cancelOnCompleted, maxSequential); + this.subscription = this.SubscribeAwait((HandleAsyncExecutionFunc: (Func, CancellationToken, ValueTask>)HandleAsyncExecution, Func: executeAsync), static (value, state, cancellationToken) => state.HandleAsyncExecutionFunc(value, state.Func, cancellationToken), awaitOperation, configureAwait, cancelOnCompleted, maxSequential); } public ReactiveCommand(Observable canExecuteSource, bool initialCanExecute) @@ -529,7 +529,7 @@ public static ReactiveCommand ToReactiveCommand( { var command = new ReactiveCommand(canExecuteSource, initialCanExecute); - var subscription = command.SubscribeAwait(executeAsync, async (x, func, ct) => await func(x, ct), awaitOperation, configureAwait, cancelOnCompleted, maxSequential); + var subscription = command.SubscribeAwait(executeAsync, static async (x, func, ct) => await func(x, ct), awaitOperation, configureAwait, cancelOnCompleted, maxSequential); command.CombineSubscription(subscription); return command;