ReactiveCommand
struct · ferroui-reactiveui · v0.5.0
struct ReactiveCommand<P, R>
A reactive command with a parameter of type P and results of type R
(ReactiveCommand<TParam, TResult>). It is a shared handle: clones are the same command.
Its factories are the associated functions of ReactiveCommand (ReactiveCommand::create,
create_from_observable, create_from_task, create_run_in_background, create_combined).
Deviation (DEVIATIONS.md, ReactiveUI): the parameter has a default (P: Default), which
Execute() and ICommand.Execute(null) pass where upstream passes default(TParam); a command
whose parameter may be missing takes an Option.
Members
createcreate_withtry_createtry_create_withcreate_paramcreate_param_withtry_create_paramtry_create_param_withcreate_run_in_backgroundcreate_run_in_background_withtry_create_run_in_backgroundtry_create_run_in_background_withcreate_run_in_background_paramcreate_run_in_background_param_withtry_create_run_in_background_paramtry_create_run_in_background_param_withcreate_combinedcreate_combined_withcreate_from_observablecreate_from_observable_withtry_create_from_observabletry_create_from_observable_withcreate_from_observable_paramcreate_from_observable_param_withtry_create_from_observable_paramtry_create_from_observable_param_withcreate_from_taskcreate_from_task_withcreate_from_task_paramcreate_from_task_param_withcreate_from_task_cancellablecreate_from_task_cancellable_withcreate_from_task_param_cancellablecreate_from_task_param_cancellable_withcan_executeis_executingthrown_exceptionsexecuteexecute_defaultas_observable
create
fn create<R: Clone + 'static>(execute: impl Fn() -> R + 'static) -> ReactiveCommand<(), R>
A command without a parameter that runs execute and notifies what it returns
(Create(Action), Create<TResult>(Func<TResult>)).
create_with
fn create_with<R: Clone + 'static>(execute: impl Fn() -> R + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
create with the observable that gates the command and the scheduler its
streams notify on (Create(Action, IObservable<bool>?, IScheduler?) and the overloads
with one of the two).
try_create
fn try_create<R: Clone + 'static>(execute: impl Fn() -> Result<R, ObservableError> + 'static) -> ReactiveCommand<(), R>
create with a function that may fail; its error goes to the execution and
to ThrownExceptions (Create with a function that throws).
try_create_with
fn try_create_with<R: Clone + 'static>(execute: impl Fn() -> Result<R, ObservableError> + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
try_create with the gate and the output scheduler.
create_param
fn create_param<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> R + 'static) -> ReactiveCommand<P, R>
A command with a parameter that runs execute with it and notifies what it returns
(Create<TParam>(Action<TParam>), Create<TParam, TResult>(Func<TParam, TResult>)).
create_param_with
fn create_param_with<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> R + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
create_param with the gate and the output scheduler.
try_create_param
fn try_create_param<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Result<R, ObservableError> + 'static) -> ReactiveCommand<P, R>
create_param with a function that may fail.
try_create_param_with
fn try_create_param_with<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Result<R, ObservableError> + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
try_create_param with the gate and the output scheduler.
create_run_in_background
fn create_run_in_background<R: Clone + 'static>(execute: impl Fn() -> R + 'static) -> ReactiveCommand<(), R>
A command without a parameter that runs execute on the background scheduler
(RxSchedulers::task_pool_scheduler by default) and notifies what it returns
(CreateRunInBackground(Action), CreateRunInBackground<TResult>(Func<TResult>)).
create_run_in_background_with
fn create_run_in_background_with<R: Clone + 'static>(execute: impl Fn() -> R + 'static, can_execute: OptionalCanExecute, background_scheduler: OptionalScheduler, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
create_run_in_background with the gate, the background
scheduler and the output scheduler (CreateRunInBackground(Action, IObservable<bool>?, IScheduler?, IScheduler?) and the overloads with some of them).
try_create_run_in_background
fn try_create_run_in_background<R: Clone + 'static>(execute: impl Fn() -> Result<R, ObservableError> + 'static) -> ReactiveCommand<(), R>
create_run_in_background with a function that may fail.
try_create_run_in_background_with
fn try_create_run_in_background_with<R: Clone + 'static>(execute: impl Fn() -> Result<R, ObservableError> + 'static, can_execute: OptionalCanExecute, background_scheduler: OptionalScheduler, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
try_create_run_in_background with the gate, the
background scheduler and the output scheduler.
create_run_in_background_param
fn create_run_in_background_param<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> R + 'static) -> ReactiveCommand<P, R>
A command with a parameter that runs execute with it on the background scheduler
(CreateRunInBackground<TParam>(Action<TParam>),
CreateRunInBackground<TParam, TResult>(Func<TParam, TResult>)).
create_run_in_background_param_with
fn create_run_in_background_param_with<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> R + 'static, can_execute: OptionalCanExecute, background_scheduler: OptionalScheduler, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
create_run_in_background_param with the gate, the
background scheduler and the output scheduler.
try_create_run_in_background_param
fn try_create_run_in_background_param<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Result<R, ObservableError> + 'static) -> ReactiveCommand<P, R>
create_run_in_background_param with a function
that may fail.
try_create_run_in_background_param_with
fn try_create_run_in_background_param_with<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Result<R, ObservableError> + 'static, can_execute: OptionalCanExecute, background_scheduler: OptionalScheduler, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
try_create_run_in_background_param with the
gate, the background scheduler and the output scheduler.
create_combined
fn create_combined<P, R, C>(child_commands: impl IntoIterator<Item = C>) -> CombinedReactiveCommand<P, R>
where P: Clone + Default + 'static,
R: Clone + 'static,
C: IReactiveCommandOf<P, R> + 'static
A command that executes every child command with its parameter, and notifies the list of
their results (CreateCombined<TParam, TResult>(IEnumerable<ReactiveCommandBase<TParam, TResult>>)).
Panics
When there is no child command (ArgumentException).
create_combined_with
fn create_combined_with<P, R, C>(child_commands: impl IntoIterator<Item = C>, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> CombinedReactiveCommand<P, R>
where P: Clone + Default + 'static,
R: Clone + 'static,
C: IReactiveCommandOf<P, R> + 'static
create_combined with the observable that gates the combined
command and the output scheduler.
create_from_observable
fn create_from_observable<R: Clone + 'static>(execute: impl Fn() -> Rc<dyn IObservable<R>> + 'static) -> ReactiveCommand<(), R>
A command without a parameter whose execution is the observable execute gives
(CreateFromObservable<TResult>(Func<IObservable<TResult>>)).
create_from_observable_with
fn create_from_observable_with<R: Clone + 'static>(execute: impl Fn() -> Rc<dyn IObservable<R>> + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
create_from_observable with the gate and the output
scheduler.
try_create_from_observable
fn try_create_from_observable<R: Clone + 'static>(execute: impl Fn() -> Result<Rc<dyn IObservable<R>>, ObservableError> + 'static) -> ReactiveCommand<(), R>
create_from_observable with a function that may fail; its
error fails the execution.
try_create_from_observable_with
fn try_create_from_observable_with<R: Clone + 'static>(execute: impl Fn() -> Result<Rc<dyn IObservable<R>>, ObservableError> + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
try_create_from_observable with the gate and the
output scheduler.
create_from_observable_param
fn create_from_observable_param<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Rc<dyn IObservable<R>> + 'static) -> ReactiveCommand<P, R>
A command with a parameter whose execution is the observable execute gives for it
(CreateFromObservable<TParam, TResult>(Func<TParam, IObservable<TResult>>)).
create_from_observable_param_with
fn create_from_observable_param_with<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Rc<dyn IObservable<R>> + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
create_from_observable_param with the gate and the
output scheduler.
try_create_from_observable_param
fn try_create_from_observable_param<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Result<Rc<dyn IObservable<R>>, ObservableError> + 'static) -> ReactiveCommand<P, R>
create_from_observable_param with a function that
may fail.
try_create_from_observable_param_with
fn try_create_from_observable_param_with<P: Clone + Default + 'static, R: Clone + 'static>(execute: impl Fn(P) -> Result<Rc<dyn IObservable<R>>, ObservableError> + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
try_create_from_observable_param with the gate
and the output scheduler.
create_from_task
fn create_from_task<R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn() -> Fut + 'static) -> ReactiveCommand<(), R>
A command without a parameter whose execution runs the future execute gives, as a task
of the thread, and notifies its result (CreateFromTask<TResult>(Func<Task<TResult>>),
CreateFromTask(Func<Task>) for R = ()). Disposing the execution does not stop the task.
create_from_task_with
fn create_from_task_with<R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn() -> Fut + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
create_from_task with the gate and the output scheduler.
create_from_task_param
fn create_from_task_param<P: Clone + Default + 'static, R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn(P) -> Fut + 'static) -> ReactiveCommand<P, R>
A command with a parameter whose execution runs the future execute gives for it
(CreateFromTask<TParam, TResult>(Func<TParam, Task<TResult>>),
CreateFromTask<TParam>(Func<TParam, Task>) for R = ()).
create_from_task_param_with
fn create_from_task_param_with<P: Clone + Default + 'static, R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn(P) -> Fut + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
create_from_task_param with the gate and the output
scheduler.
create_from_task_cancellable
fn create_from_task_cancellable<R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn(CancellationToken) -> Fut + 'static) -> ReactiveCommand<(), R>
A command without a parameter whose execution runs the future execute gives for a
cancellation token; disposing the execution cancels the token, and the command stays
executing until the future ends (CreateFromTask<TResult>(Func<CancellationToken, Task<TResult>>), CreateFromTask(Func<CancellationToken, Task>) for R = ()).
create_from_task_cancellable_with
fn create_from_task_cancellable_with<R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn(CancellationToken) -> Fut + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<(), R>
create_from_task_cancellable with the gate and the
output scheduler.
create_from_task_param_cancellable
fn create_from_task_param_cancellable<P: Clone + Default + 'static, R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn(P, CancellationToken) -> Fut + 'static) -> ReactiveCommand<P, R>
A command with a parameter whose execution runs the future execute gives for it and a
cancellation token (CreateFromTask<TParam, TResult>(Func<TParam, CancellationToken, Task<TResult>>), CreateFromTask<TParam>(Func<TParam, CancellationToken, Task>) for
R = ()).
create_from_task_param_cancellable_with
fn create_from_task_param_cancellable_with<P: Clone + Default + 'static, R: Clone + 'static, Fut: Future<Output = Result<R, ObservableError>> + 'static>(execute: impl Fn(P, CancellationToken) -> Fut + 'static, can_execute: OptionalCanExecute, output_scheduler: OptionalScheduler) -> ReactiveCommand<P, R>
create_from_task_param_cancellable with the
gate and the output scheduler.
can_execute
fn can_execute(self: &Self) -> Rc<dyn IObservable<bool>>
Whether the command can execute: the current value on subscription, then each change. It is
false while an execution is in flight, and false after the gate failed (CanExecute).
is_executing
fn is_executing(self: &Self) -> Rc<dyn IObservable<bool>>
Whether the command is executing: the current value on subscription, then each change
(IsExecuting).
thrown_exceptions
fn thrown_exceptions(self: &Self) -> Rc<dyn IObservable<ObservableError>>
The errors of the executions and of the gate, on the output scheduler
(ThrownExceptions). While nothing observes it, an error goes to
RxState::default_exception_handler.
execute
fn execute(self: &Self, parameter: P) -> Rc<dyn IObservable<R>>
An observable that executes the command with parameter each time it is subscribed, and
notifies the results of that execution (Execute(TParam)). Nothing runs until it is
subscribed; disposing the subscription cancels the execution.
execute_default
fn execute_default(self: &Self) -> Rc<dyn IObservable<R>>
execute with the default parameter (Execute()).
as_observable
fn as_observable(self: &Self) -> Rc<dyn IObservable<R>>
The command as the observable of its results, which the operators take.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedSubscribeGuard<T>CommandValueClonePartialEqDebugIObservable<R>IDisposableIHandleObservableErrorsIReactiveCommandIReactiveCommandOf<P, R>ICommand
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.