Skip to content

Commit

Permalink
Refactor command execution handling
Browse files Browse the repository at this point in the history
- Updated subscription logic for command execution.
- Improved async handling in subscription methods.
  • Loading branch information
michaelstonis committed Dec 6, 2024
1 parent 389a768 commit dbf590a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/R3/ReactiveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public ReactiveCommand(Action<T> execute)
{
this.list = new FreeListCore<Subscription>(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<T, Action<T>>)HandleExecution, Action: execute), static (value, state) => state.HandleExecutionAction(value, state.Action));
}

public ReactiveCommand(Func<T, CancellationToken, ValueTask> executeAsync, AwaitOperation awaitOperation = AwaitOperation.Sequential, bool configureAwait = true, bool cancelOnCompleted = false, int maxSequential = -1)
{
this.list = new FreeListCore<Subscription>(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<T, Func<T, CancellationToken, ValueTask>, CancellationToken, ValueTask>)HandleAsyncExecution, Func: executeAsync), static (value, state, cancellationToken) => state.HandleAsyncExecutionFunc(value, state.Func, cancellationToken), awaitOperation, configureAwait, cancelOnCompleted, maxSequential);
}

public ReactiveCommand(Observable<bool> canExecuteSource, bool initialCanExecute)
Expand Down Expand Up @@ -529,7 +529,7 @@ public static ReactiveCommand<T> ToReactiveCommand<T>(
{
var command = new ReactiveCommand<T>(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;
Expand Down

0 comments on commit dbf590a

Please sign in to comment.