ObservableAsPropertyHelper
struct · ferroui-reactiveui · v0.5.0
struct ObservableAsPropertyHelper<T: 'static>
Backs a read-only output property with an observable: the property reports each new value
through the callbacks it was created with, so that its owner raises its own change
notifications (ObservableAsPropertyHelper<T>).
It is normally made by to_property,
whose callbacks raise the owner's notifications for the named property; it can also be made
directly with callbacks of one's own. A view model stores it (in a OnceCell or a
RefCell<Option<..>>) and reads value in its getter.
Values equal to the previous one are skipped. Without a scheduler, or with the immediate one, each value is delivered at once; a value produced while another is being delivered waits for that delivery to end, so the callbacks never nest.
The helper is a shared handle: its clones are the same helper.
Members
newwith_initial_valuewith_initial_value_onwith_initial_value_deferredwith_changingwith_optionscreatedefault_with_initial_valuedefault_with_initial_value_onvalueis_subscribedthrown_exceptions
new
fn new(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static) -> Self
where T: Default
A helper that follows observable from the default value of T, running on_changed
with each new value (ObservableAsPropertyHelper(IObservable<T?>, Action<T?>)).
with_initial_value
fn with_initial_value(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, initial_value: T) -> Self
A helper that starts from initial_value
(ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, T?)).
with_initial_value_on
fn with_initial_value_on(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, initial_value: T, scheduler: Option<Rc<dyn IScheduler>>) -> Self
A helper that starts from initial_value and delivers its values on scheduler
(ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, T?, ISequencer?)).
with_initial_value_deferred
fn with_initial_value_deferred(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, initial_value: T, defer_subscription: bool) -> Self
A helper that starts from initial_value and, when defer_subscription is set, subscribes
to observable on the first read of value
(ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, T?, bool)).
with_changing
fn with_changing(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, on_changing: impl Fn(T) -> () + 'static) -> Self
where T: Default
A helper with a callback run before each new value is stored, as well as the one run after
(ObservableAsPropertyHelper(IObservable<T?>, Action<T?>, Action<T?>?)).
with_options
fn with_options(observable: Rc<dyn IObservable<T>>, on_changed: impl Fn(T) -> () + 'static, on_changing: Option<Rc<dyn Fn(T) -> ()>>, initial_value: ObservableAsPropertyInitialValue<T>, defer_subscription: bool, scheduler: Option<Rc<dyn IScheduler>>) -> Self
The helper with every option: on_changing runs before each new value is stored and
on_changed after; initial_value is a value or a factory; defer_subscription delays the
subscription to the first read of value; scheduler delivers the values
(the other constructors of upstream, which this one covers).
create
fn create<O: 'static>(observable: Rc<dyn IObservable<T>>, owner: &Rc<O>, on_changed: impl Fn(&Rc<O>, T) -> () + 'static, on_changing: Option<Rc<dyn Fn(&Rc<O>, T) -> ()>>, initial_value: ObservableAsPropertyInitialValue<T>, defer_subscription: bool, scheduler: Option<Rc<dyn IScheduler>>) -> Self
A helper whose callbacks take its owner, which the helper holds weakly: once the owner is
dropped, the callbacks are not run (Create(IObservable<T?>, object, Action<object?, T?>, Action<object?, T?>?, T?, bool, ISequencer?), the factory that ToProperty uses).
default_with_initial_value
fn default_with_initial_value(initial_value: T) -> Self
A helper that holds initial_value and never changes (Default(T?)).
default_with_initial_value_on
fn default_with_initial_value_on(initial_value: T, scheduler: Option<Rc<dyn IScheduler>>) -> Self
A helper that holds initial_value, delivered on scheduler, and never changes
(Default(T?, ISequencer?)).
value
fn value(self: &Self) -> T
The last value of the property; a deferred helper subscribes on its first read (Value).
is_subscribed
fn is_subscribed(self: &Self) -> bool
Whether the helper has subscribed to its source (IsSubscribed).
thrown_exceptions
fn thrown_exceptions(self: &Self) -> Rc<dyn IObservable<ObservableError>>
The errors of the source (ThrownExceptions). While it has no observer, an error goes to
RxState::default_exception_handler.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedCloneDefaultIDisposable
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.