ViewModelActivator
struct · ferroui-reactiveui · v0.5.0
struct ViewModelActivator
The helper a view model holds to take part in activation (ViewModelActivator).
The view calls it when it comes on screen: the view model then sets up what should only live
while it is shown, such as subscriptions to global objects, and tears it down when the view
leaves. Register what to do with
when_activated.
Activation is not loading: a view is activated when it enters the visual tree and deactivated when it leaves it, which matters for views that are recycled. Activations are counted: the view model is deactivated when every activation has been matched by a deactivation.
Create the activator once, in the most basic view model of a hierarchy, and let the others use
it. The view that shows the view model must set up its own activation
(ViewForMixins).
The activator is a shared handle: a clone is the same activator.
Members
new
fn new() -> Self
An activator without blocks, not activated (ViewModelActivator()).
activated
fn activated(self: &Self) -> Rc<dyn IObservable<()>>
Ticks each time the activator is activated (Activated).
deactivated
fn deactivated(self: &Self) -> Rc<dyn IObservable<()>>
Ticks each time the activator is deactivated (Deactivated).
activate
fn activate(self: &Self) -> Rc<dyn IDisposable>
Activates the view model: on the first activation, runs the registered blocks and ticks
activated (Activate()). The view calls it when it is activated; a
unit test calls it to simulate that.
Returns a disposable that calls deactivate.
deactivate
fn deactivate(self: &Self)
Deactivates the view model, following the count of activations: the blocks' disposables
are disposed and deactivated ticks when the last activation is
matched (Deactivate()). The view calls it when it is deactivated.
deactivate_with
fn deactivate_with(self: &Self, ignore_ref_count: bool)
deactivate; with ignore_ref_count, the view model is deactivated
even when it was activated more than once (Deactivate(bool)).
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedCloneDefaultDebugPartialEqIDisposable
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.