BindCommandMixins
trait · ferroui-reactiveui · v0.5.0
trait BindCommandMixins<V: 'static>
BindCommand: binds the command a property of a view model holds to the control a property of
a view holds, rebinding when either changes. Implemented for every Rc of a view.
Upstream's source generator roots the command at the view's ViewModel when the view declares
one: the binding follows the view model the view displays, and binds nothing while there is
none. bind_command and its _with_ forms do that for a view that
declares its view model (IViewForOf<VM>), observed as the property ViewModel of the view; the _on
forms root the command at a given view model, as for a view that does not declare one, and bind
nothing without a view model.
The command binds to to_event (ToEvent); without one, to the default event of the
control, through the registered binder with the highest affinity for the type of the control
(CommandBinderService). The command executes with the latest value of the command
parameter, if it can execute with it.
Deviation (DEVIATIONS.md, ReactiveUI): upstream overloads BindCommand by the source of the
parameter (none, an observable, an expression) and resolves the root and the event at compile
time; here each is a method of its own, the event is a ToEvent, and the view-rooted forms
leave out upstream's viewModel argument, which the generated code does not read either. The
expressions are PropertyPaths. A control no binder supports binds nothing, as upstream's
run-time path does (the generated code throws when it finds no event at compile time).
Members
bind_commandbind_command_with_parameterbind_command_with_parameter_pathbind_command_onbind_command_with_parameter_onbind_command_with_parameter_path_on
bind_command
fn bind_command<VM, X, CV>(self: &Self, command: PropertyPath<Rc<VM>, X>, control: PropertyPath<Rc<V>, CV>, to_event: Option<ToEvent<<CV as >::Control>>) -> Rc<dyn IDisposable>
where V: IViewForOf<VM>,
VM: 'static,
X: CommandValue,
CV: ControlValue
Binds the command command reads from the view's view model to the control control reads
from the view (BindCommand(viewModel, propertyName, controlName, toEvent)).
bind_command_with_parameter
fn bind_command_with_parameter<VM, X, CV, P>(self: &Self, command: PropertyPath<Rc<VM>, X>, control: PropertyPath<Rc<V>, CV>, parameter: Rc<dyn IObservable<P>>, to_event: Option<ToEvent<<CV as >::Control>>) -> Rc<dyn IDisposable>
where V: IViewForOf<VM>,
VM: 'static,
X: CommandValue,
CV: ControlValue,
P: 'static
bind_command with the values of parameter as the command
parameter (BindCommand(..., IObservable<TParam?> withParameter, toEvent)).
bind_command_with_parameter_path
fn bind_command_with_parameter_path<VM, X, CV, P>(self: &Self, command: PropertyPath<Rc<VM>, X>, control: PropertyPath<Rc<V>, CV>, parameter: PropertyPath<Rc<VM>, P>, to_event: Option<ToEvent<<CV as >::Control>>) -> Rc<dyn IDisposable>
where V: IViewForOf<VM>,
VM: 'static,
X: CommandValue,
CV: ControlValue,
P: Clone + PartialEq + 'static
bind_command with the property parameter of the view's view model
as the command parameter, observed so that the control sees each of its values
(BindCommand(..., Expression<Func<TViewModel, TParam?>> withParameter, toEvent)).
bind_command_on
fn bind_command_on<VM, X, CV>(self: &Self, view_model: Option<Rc<VM>>, command: PropertyPath<Rc<VM>, X>, control: PropertyPath<Rc<V>, CV>, to_event: Option<ToEvent<<CV as >::Control>>) -> Rc<dyn IDisposable>
where VM: 'static,
X: CommandValue,
CV: ControlValue
bind_command rooted at view_model.
bind_command_with_parameter_on
fn bind_command_with_parameter_on<VM, X, CV, P>(self: &Self, view_model: Option<Rc<VM>>, command: PropertyPath<Rc<VM>, X>, control: PropertyPath<Rc<V>, CV>, parameter: Rc<dyn IObservable<P>>, to_event: Option<ToEvent<<CV as >::Control>>) -> Rc<dyn IDisposable>
where VM: 'static,
X: CommandValue,
CV: ControlValue,
P: 'static
bind_command_with_parameter rooted at view_model.
bind_command_with_parameter_path_on
fn bind_command_with_parameter_path_on<VM, X, CV, P>(self: &Self, view_model: Option<Rc<VM>>, command: PropertyPath<Rc<VM>, X>, control: PropertyPath<Rc<V>, CV>, parameter: PropertyPath<Rc<VM>, P>, to_event: Option<ToEvent<<CV as >::Control>>) -> Rc<dyn IDisposable>
where VM: 'static,
X: CommandValue,
CV: ControlValue,
P: Clone + PartialEq + 'static
bind_command_with_parameter_path rooted at
view_model.
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.