ReactiveNavigation class

Namespace Runic.Navigation.ReactiveUI · Runic.Navigation.ReactiveUI 0.7.0-preview.5

public static class ReactiveNavigation

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, NavigationResult<TContent>> CreateBackCommand<TContent>(this NavigationRegion<TContent> region, ISequencer scheduler) where TContent : class

Creates a command that goes back in region. It can execute while NavigationRegion.CanGoBack is true and NavigationRegion.IsTransitioning is false, and its output is the NavigationResult. CanExecute reflects this region only: a transition of an ancestor region does not disable it.

Parameters

region

The region.

scheduler

The scheduler of the command's output and CanExecute, such as the model context's scheduler from IRunicReactiveSchedulerProvider.

Remarks

A rejected, superseded or failed Back is a result, not an exception, so ThrownExceptions reports only defects and cancellation. Subscribe to the command's ThrownExceptions; without a subscriber ReactiveUI routes them to its default exception handler. Apps that use Runic Views can use RunicReactiveExceptions.ObserveBridgeExceptions from Runic.Application.ReactiveUI. 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, so dispose it with its owner, for example with DisposeWith.

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 ReactiveNavigation.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 ReactiveNavigation.WhenEntryChanged to see every entry.

Remarks

The sequence never completes; dispose the subscription to stop observing.

WhenEntryChanged

public static IObservable<NavigationEntry<TContent>?> WhenEntryChanged<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.

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.