RoutingState
struct · ferroui-reactiveui · v0.5.0
struct RoutingState
The stack of view models of a screen, and the commands that navigate it (RoutingState).
An IScreen holds one to coordinate the navigation of an application of
several pages. The stack is last in, first out: navigate pushes a view
model, navigate_back pops one, and
navigate_and_reset replaces the whole stack.
Every notification of the navigation is an observable of values:
current_view_model gives the view model on top of the stack,
navigation_stack_changed gives the whole stack after each
change, and can_navigate_back whether there is a view model to go
back to.
The router is shared (Rc<RoutingState>); its observables and commands refer to it weakly, so
that they do not keep it alive.
Members
newwith_schedulernavigation_stackset_navigation_stacknavigate_backset_navigate_backnavigateset_navigatenavigate_and_resetset_navigate_and_resetcurrent_view_modelset_current_view_modelnavigation_stack_changedset_navigation_stack_changedcan_navigate_backset_can_navigate_back
new
fn new() -> Rc<Self>
A router with an empty stack, whose navigation notifies on
RxSchedulers::main_thread_scheduler (RoutingState()).
with_scheduler
fn with_scheduler(scheduler: Option<Rc<dyn IScheduler>>) -> Rc<Self>
A router whose navigation notifies on scheduler, or on
RxSchedulers::main_thread_scheduler when None (RoutingState(IScheduler?)).
navigation_stack
fn navigation_stack(self: &Self) -> NavigationStack
The navigation stack, the last view model being the current one (NavigationStack).
set_navigation_stack
fn set_navigation_stack(self: &Self, value: NavigationStack)
Replaces the navigation stack (NavigationStack { set; }). The observables observe the
stack the router has when they are subscribed.
navigate_back
fn navigate_back(self: &Self) -> NavigateBackCommand
Navigates back to the previous view model of the stack, and emits the new current one
(NavigateBack). It can execute while the stack holds at least two view models.
set_navigate_back
fn set_navigate_back(self: &Self, value: NavigateBackCommand)
Replaces navigate_back (its protected setter).
navigate
fn navigate(self: &Self) -> NavigateCommand
Pushes a view model on the stack, and emits it once the navigation scheduler delivers it
(Navigate). Executing it with None fails, as upstream fails for null.
set_navigate
fn set_navigate(self: &Self, value: NavigateCommand)
Replaces navigate (its protected setter).
navigate_and_reset
fn navigate_and_reset(self: &Self) -> NavigateCommand
Replaces the whole stack with a view model, clearing the history of the navigation
(NavigateAndReset).
set_navigate_and_reset
fn set_navigate_and_reset(self: &Self, value: NavigateCommand)
Replaces navigate_and_reset (its protected setter).
current_view_model
fn current_view_model(self: &Self) -> Rc<dyn IObservable<Option<RoutableViewModel>>>
The view model on top of the stack: the current one on subscription, then again after
every change of the stack; None while the stack is empty (CurrentViewModel).
set_current_view_model
fn set_current_view_model(self: &Self, value: Rc<dyn IObservable<Option<RoutableViewModel>>>)
Replaces current_view_model (its protected setter).
navigation_stack_changed
fn navigation_stack_changed(self: &Self) -> Rc<dyn IObservable<NavigationStackSnapshot>>
A copy of the whole stack after each change of navigation_stack,
oldest first; nothing on subscription (NavigationStackChanged).
set_navigation_stack_changed
fn set_navigation_stack_changed(self: &Self, value: Rc<dyn IObservable<NavigationStackSnapshot>>)
Replaces navigation_stack_changed (its protected
setter); current_view_model and
can_navigate_back follow the replacement.
can_navigate_back
fn can_navigate_back(self: &Self) -> Rc<dyn IObservable<bool>>
Whether there is a view model to go back to, which holds while the stack has at least two:
the current answer on subscription, then each change of it (CanNavigateBack).
set_can_navigate_back
fn set_can_navigate_back(self: &Self, value: Rc<dyn IObservable<bool>>)
Replaces can_navigate_back (its protected setter).
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeIReactiveObjectExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>AnyINotifyPropertyChangedINotifyPropertyChangingIEnableLoggerIReactiveObjectIHandleObservableErrorsDebugPartialEqRoutingStateMixins
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.