public static class ReactiveNavigationRegionExtensions Observes a NavigationRegion and goes back with a ReactiveUI command. The navigator replaces ReactiveUI's RoutingState; these helpers do not wrap one.
Remarks
Each subscription receives its initial value on the subscribing thread, inside Subscribe. Later values arrive on the model turn in which the region raises the change; content changes arrive on the navigation's commit turn. Use ObserveOn to move to another scheduler. An entry's lifetime is not ReactiveUI activation: a retained entry stays alive while it is not presented, and its View may deactivate and activate again when it returns.
Methods
CreateBackCommand
public static ReactiveCommand<RxVoid, NavigationOutcome> CreateBackCommand<TContent>(this NavigationRegion<TContent> region, IObservable<bool>? canExecute = null, ISequencer? outputScheduler = null) where TContent : class Creates a command that goes back in region and outputs the NavigationResult.Outcome, a NavigationOutcome that a Runic View can receive. It can execute while NavigationRegion.CanGoBack is true and NavigationRegion.IsTransitioning is false, and, for a region that admits requests with NavigationAdmission.RejectWhileBusy, while NavigationRegion.IsBusy is false. CanExecute reflects this region only: a transition of an ancestor region does not disable it.
Parameters
regionThe region.
canExecuteAn additional condition for the command, such as "not saving", combined with the region's condition: the command can execute while both are
true.nulluses the region's condition alone. Until it emits its first value, the command can't execute.outputSchedulerThe scheduler of the command's output and
IsExecuting, ornullfor ReactiveUI's main-thread scheduler, as anyReactiveCommanduses: in a Runic Views app,AddRunicReactiveModelContextfromRunic.Application.Views.ReactiveUImakes that the model context of the turn that executes the command, and in a WPF app it is the dispatcher.
Remarks
A rejected, superseded or failed Back is an outcome, not an exception, so ThrownExceptions reports only defects and cancellation. While a generated Runic Views Bridge presents the command, it logs those defects; otherwise, without a ThrownExceptions subscriber, ReactiveUI routes them to its default exception handler. Code that needs the full NavigationResult, such as a failure's exception, awaits NavigationRegion.BackAsync in its own command. Overlapping executions to the same destination share one Back and confirmation. Cancelling one execution cancels that caller; the shared Back is cancelled only when every caller cancels before commit. The command observes the region through a PropertyChanged handler until the command is disposed. A command whose owner lives as long as the region, such as a shell ViewModel's command on its own region, needs no disposal: they become unreachable together. Dispose it with its owner only when the region outlives the owner, such as a page's command on its parent's region.
WhenCanGoBackChanged
public static IObservable<bool> WhenCanGoBackChanged<TContent>(this NavigationRegion<TContent> region) where TContent : class Observes whether the region has Back history. Each subscription receives the current value and then each different value. This does not include transition availability; compose with ReactiveNavigationRegionExtensions.WhenIsTransitioningChanged when creating a command.
Remarks
The sequence never completes; dispose the subscription to stop observing.
WhenCurrentChanged
public static IObservable<TContent?> WhenCurrentChanged<TContent>(this NavigationRegion<TContent> region) where TContent : class Observes the region's NavigationRegion.Current content. Each subscription receives the current value, or null when the region is empty, and then each different instance. Pushing the same borrowed instance again does not emit; observe ReactiveNavigationRegionExtensions.WhenCurrentEntryChanged to see every entry.
Remarks
The sequence never completes; dispose the subscription to stop observing.
WhenCurrentEntryChanged
public static IObservable<NavigationEntry<TContent>?> WhenCurrentEntryChanged<TContent>(this NavigationRegion<TContent> region) where TContent : class Observes the region's NavigationRegion.CurrentEntry. Each subscription receives the current entry, or null when the region is empty, and then each different entry, also when two entries present the same content.
Remarks
The sequence never completes; dispose the subscription to stop observing.
WhenHistoryChanged
public static IObservable<IReadOnlyList<NavigationEntry<TContent>>> WhenHistoryChanged<TContent>(this NavigationRegion<TContent> region) where TContent : class Observes the region's NavigationRegion.History, the retained entries below the current entry, from bottom to top. Each subscription receives the current history, empty when the region has none, and then each different history, in the commit turn of a request that changes it, such as a push, Back, ResetAsync or ClearHistoryAsync. A request that changes only the current entry, such as a replace, does not emit.
Remarks
Each value is a snapshot that does not change afterwards; bind a history list or breadcrumb to it. The sequence never completes; dispose the subscription to stop observing.
WhenIsBusyChanged
public static IObservable<bool> WhenIsBusyChanged<TContent>(this NavigationRegion<TContent> region) where TContent : class Observes whether the region is busy (NavigationRegion.IsBusy): a request of the region, including one started by another caller, has not completed. Each subscription receives the current value and then each different value observed when the region raises a change. Unlike ReactiveNavigationRegionExtensions.WhenIsTransitioningChanged, it stays true after the commit until the request's task completes.
Remarks
The sequence never completes; dispose the subscription to stop observing.
WhenIsTransitioningChanged
public static IObservable<bool> WhenIsTransitioningChanged<TContent>(this NavigationRegion<TContent> region) where TContent : class Observes whether the region has an unsettled transition, including operations started by other callers. Each subscription receives the current value and then each different value observed when the region raises a change. An ancestor's transitions are not included.
Remarks
The sequence never completes; dispose the subscription to stop observing.