ReactiveCommandExecutionExtensions class

Namespace Runic.Application.Views.ReactiveUI in Runic.Application.Views.ReactiveUI 0.23.0

public static class ReactiveCommandExecutionExtensions

Runs a ReactiveUI command from hand-written code the way a generated Bridge call runs it.

Methods

RunAsync

public static Task RunAsync<TInput, TResult>(this IReactiveCommand<TInput, TResult> command, TInput input, CancellationToken cancellationToken = default)

Executes command with input and completes when the execution completes, after zero or more values, as a generated Bridge call of a command without a result does. A command that produces no value completes normally; the values are not returned.

Type parameters

TInput

The command's input type.

TResult

The command's output type.

Parameters

command

The command.

input

The command's input.

cancellationToken

Cancels and disposes the execution.

Returns

A task that completes when the execution completes, fails with its exception, or is cancelled.

Exceptions

ArgumentNullException

command is null.

Remarks

Use it in hand-written code that runs a command on behalf of a Bridge call or inside a model turn, such as a wrapper command that a Bridge presents and that runs a native command whose input has no wire form, when the code handles the command's failure itself, runs outside any Bridge call, or needs completion without a value. A failure of the execution is rethrown unchanged, and Runic counts it as received by this call: it is never logged as ReactiveCommandFailed (Views event 1042), whether the caller lets it propagate, wraps it or handles it, inside or outside a Bridge call. Failures of other executions of the command that arrive while this one runs are held until it ends and are logged then, as during a Bridge call.

The execution's notifications follow the model turn that started it, as for a bridged execution. Cancelling cancellationToken disposes the execution, which cancels a token-taking CreateFromTask body, and the returned task is cancelled. A token that is already cancelled does not start it.

A plain await command.Execute(input) is enough inside a Bridge call when the exception propagates or is wrapped: the Bridge call receives it. The Views.ReactiveUI guide's "Which call to use" section compares them.