Table of Contents

Class RoutableViewModelMixin

Namespace
ReactiveUI
Assembly
ReactiveUI.dll

Extension methods associated with the IRoutableViewModel interface.

public static class RoutableViewModelMixin : Object
Inheritance
RoutableViewModelMixin

Methods

WhenNavigatedTo(IRoutableViewModel, Func<IDisposable>)

This method allows you to set up connections that only operate while the ViewModel has focus, and cleans up when the ViewModel loses focus.

public static IDisposable WhenNavigatedTo(this IRoutableViewModel item, Func<IDisposable> onNavigatedTo)

Parameters

item IRoutableViewModel

The ViewModel to watch for focus changes.

onNavigatedTo Func<IDisposable>

Called when the ViewModel is navigated to - return an IDisposable that cleans up all of the things that are configured in the method.

Returns

IDisposable

An IDisposable that lets you disconnect the entire process earlier than normal.

WhenNavigatedToObservable(IRoutableViewModel)

This method will return an observable that fires events every time the topmost ViewModel in the navigation stack is this ViewModel. This allows you to set up connections that only operate while the ViewModel has focus.

The observable will complete when the ViewModel is removed completely from the navigation stack. If your ViewModel can be _removed_ from the navigation stack and then reused later, you must call this method and resubscribe each time it is reused.

public static IObservable<Unit> WhenNavigatedToObservable(this IRoutableViewModel item)

Parameters

item IRoutableViewModel

The ViewModel to watch for navigation changes.

Returns

IObservable<Unit>

An IObservable{Unit} that signals when the ViewModel has been added or brought to the top of the navigation stack. The observable completes when the ViewModel is no longer a part of the navigation stack.

WhenNavigatingFromObservable(IRoutableViewModel)

This method will return an observable that fires events _just before_ the ViewModel is no longer the topmost ViewModel in the navigation stack. This allows you to clean up anything before losing focus.

The observable will complete when the ViewModel is removed completely from the navigation stack. If your ViewModel can be _removed_ from the navigation stack and then reused later, you must call this method and resubscribe each time it is reused.

public static IObservable<Unit> WhenNavigatingFromObservable(this IRoutableViewModel item)

Parameters

item IRoutableViewModel

The ViewModel to watch for navigation changes.

Returns

IObservable<Unit>

An IObservable{Unit} that signals when the ViewModel is no longer the topmost ViewModel in the navigation stack. The observable completes when the ViewModel is no longer a part of the navigation stack.