PropertyBindingMixins
trait · ferroui-reactiveui · v0.5.0
trait PropertyBindingMixins<V: IViewFor + INotifyPropertyChanged + 'static>
The bindings of a view to its view model (ReactiveUIBindingExtensions.OneWayBind, Bind, and
their forms of ReactiveSchedulerExtensions); implemented for every Rc<V> of a view V.
The view model. A view typed for the view model (one that implements
IViewForOf<VM>, as view_for! writes it) binds
through its own view model: the binding follows the view's ViewModel, so that replacing the
view model (with the view raising PropertyChanged for ViewModel) rebinds, and a view without
one waits for it; view_model only names its type. A view that names no type of view model
binds the view_model handed in. A binding with no view model binds nothing, and does not fail.
The writes. The view property is written on the thread that owns the view (through the
registered IViewThreadInvoker), or on the scheduler the call
names, and only when it does not hold the value already. A two-way binding seeds the view from
the view model, then mirrors each later change of either side; the view's own value at the start
is not written back.
The conversions. Without functions, a value is converted by the converter the call names,
else by the one registered for the pair of types in
BindingConverters, else passed when it already is of the target
type; a value that cannot be converted is not written.
A registered IPropertyBindingHook may refuse a binding: the
method then returns None. The binding holds its view weakly in its writes; the
IReactiveBinding it returns holds it.
Members
one_way_bindone_way_bind_selectone_way_bind_select_onone_way_bind_withbindbind_selectbind_select_onbind_withbind_with_triggerbind_select_with_trigger
one_way_bind
fn one_way_bind<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
Binds view_model_property one way to view_property: the current value and each later
change are written to the view (OneWayBind(TViewModel?, Expression, Expression)).
one_way_bind_select
fn one_way_bind_select<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, selector: impl Fn(TVM) -> TV + 'static) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
one_way_bind through selector
(OneWayBind(TViewModel?, Expression, Expression, Func<TProp, TOut>)).
one_way_bind_select_on
fn one_way_bind_select_on<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, selector: impl Fn(TVM) -> TV + 'static, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
one_way_bind_select, writing on scheduler, or on the
view's thread when it is None (ReactiveSchedulerExtensions.OneWayBind(..., Func<TProp, TOut>, ISequencer?)).
one_way_bind_with
fn one_way_bind_with<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: PropertyPath<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, converter: Option<Rc<dyn IBindingTypeConverter>>, conversion_hint: Option<Rc<dyn Any>>, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, TV>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
one_way_bind, converting with converter instead of a registered
converter when it is given, with conversion_hint, and writing on scheduler, or on the
view's thread when it is None (ReactiveSchedulerExtensions.OneWayBind(..., IBindingTypeConverter, object?, ISequencer?)).
bind
fn bind<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
Binds view_model_property and view_property to each other: the view is seeded from the
view model, then each change of either side is written to the other
(Bind(TViewModel?, Expression, Expression)). The change stream of the binding reports each
value written, with the side it came from.
bind_select
fn bind_select<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view: impl Fn(TVM) -> TV + 'static, view_to_view_model: impl Fn(TV) -> TVM + 'static) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
bind through view_model_to_view and view_to_view_model
(Bind(TViewModel?, Expression, Expression, Func<TVMProp, TVProp>, Func<TVProp, TVMProp>)).
bind_select_on
fn bind_select_on<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view: impl Fn(TVM) -> TV + 'static, view_to_view_model: impl Fn(TV) -> TVM + 'static, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
bind_select, writing to the view on scheduler, or on the view's
thread when it is None; on a scheduler, only the latest value that waits is written
(ReactiveSchedulerExtensions.Bind(..., Func, Func, ISequencer?)).
bind_with
fn bind_with<VM, TVM, TV>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view_converter: Option<Rc<dyn IBindingTypeConverter>>, view_to_view_model_converter: Option<Rc<dyn IBindingTypeConverter>>, conversion_hint: Option<Rc<dyn Any>>, scheduler: Option<Rc<dyn IScheduler>>) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static
bind, converting with view_model_to_view_converter and
view_to_view_model_converter instead of the registered converters when they are given,
with conversion_hint, and writing to the view on scheduler, or on the view's thread when
it is None (ReactiveSchedulerExtensions.Bind(..., IBindingTypeConverter, IBindingTypeConverter, object?, ISequencer?)).
bind_with_trigger
fn bind_with_trigger<VM, TVM, TV, D>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, signal_view_update: Option<Rc<dyn IObservable<D>>>, trigger_update: TriggerUpdate) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static,
D: 'static
Binds view_model_property and view_property to each other, driven by direction
signals (BindUnsafe(..., IObservable<TDontCare>? signalViewUpdate, TriggerUpdate)).
Without signal_view_update, a change of either side is written to the other. With it,
TriggerUpdate::ViewToViewModel writes the view to the view model only when the stream
produces a value (the changes of the view are not observed), and
TriggerUpdate::ViewModelToView writes the view model to the view only when the stream
produces a value (the changes of the view are still written back). The current values are
read on the view's thread when a signal is delivered, so a signal that waited writes the
values of its delivery. The view is always initialized from the view model.
bind_select_with_trigger
fn bind_select_with_trigger<VM, TVM, TV, D>(self: &Self, view_model: impl Into<Option<Rc<VM>>>, view_model_property: SettableProperty<Rc<VM>, TVM>, view_property: SettableProperty<Rc<V>, TV>, view_model_to_view: impl Fn(TVM) -> TV + 'static, view_to_view_model: impl Fn(TV) -> TVM + 'static, signal_view_update: Option<Rc<dyn IObservable<D>>>, trigger_update: TriggerUpdate) -> Option<Rc<dyn IReactiveBinding<V, BindingChange>>>
where VM: 'static,
TVM: Clone + PartialEq + 'static,
TV: Clone + PartialEq + 'static,
D: 'static
bind_with_trigger through view_model_to_view and
view_to_view_model (BindUnsafe(..., Func, Func, IObservable<TDontCare>?, TriggerUpdate)).
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.