Add Stack Routing API
Summary
This RFC is based on https://github.com/reactiveui/ReactiveUI/issues/1107
The current implementation of RoutingState exposes navigation as a set of commands on an ObservableCollection<IRoutableViewModel>
Xamarin.Forms has built in navigation based on a stack data structure.
public interface INavigation
{
IReadOnlyList<Page> ModalStack { get; }
IReadOnlyList<Page> NavigationStack { get; }
void InsertPageBefore(Page page, Page before);
Task<Page> PopAsync();
Task<Page> PopAsync(bool animated);
Task<Page> PopModalAsync();
Task<Page> PopModalAsync(bool animated);
Task PopToRootAsync();
Task PopToRootAsync(bool animated);
Task PushAsync(Page page);
Task PushAsync(Page page, bool animated);
Task PushModalAsync(Page page);
Task PushModalAsync(Page page, bool animated);
void RemovePage(Page page);
}
Motivation
The current RoutingState currently has no support for the following concerns:
- Animation
- Navigation and Modal stack
- Passing parameters on navigation
I am proposing we introduce a reactive abstraction base on Custom Routing in ReactiveUI. This would provide view model based navigation and better reflect stack navigation patterns.
public interface IRoutingStack
{
IObservable<IImmutableList<IRoutableViewModel>> ModalStack { get; }
IObservable<IImmutableList<IRoutableViewModel>> PageStack { get; }
IView View { get; }
IObservable<Unit> PopModal(bool animate = true);
IObservable<Unit> PopPage(bool animate = true);
IObservable<Unit> PopTo<TViewModel>() where TViewModel : IRoutableViewModel;
IObservable<Unit> PopToRootPage(bool animate = true);
IObservable<Unit> PushModal(IRoutableViewModel modal, string contract = null);
IObservable<Unit> PushPage(IRoutableViewModel page, string contract = null, bool resetStack = false, bool animate = true);
IObservable<IRoutableViewModel> TopModal();
IObservable<IRoutableViewModel> TopPage();
}
Discussion
I know there are benefits to the current RoutingState implementation, I want to make this an option for stack based navigation platforms.
Questions
How do we handle platforms that don't have a concept of a modal stack?
If we implement passing parameters does it make sense for all platforms?
Do we allow consumers to implement their own IRoutingStack and register it for use with ReactiveUI?
Are there any performance concerns or improvements that could come from this change?
Add Stack Routing API
Summary
This RFC is based on https://github.com/reactiveui/ReactiveUI/issues/1107
The current implementation of
RoutingStateexposes navigation as a set of commands on anObservableCollection<IRoutableViewModel>Xamarin.Forms has built in navigation based on a stack data structure.
Motivation
The current
RoutingStatecurrently has no support for the following concerns:I am proposing we introduce a reactive abstraction base on Custom Routing in ReactiveUI. This would provide view model based navigation and better reflect stack navigation patterns.
Discussion
I know there are benefits to the current
RoutingStateimplementation, I want to make this an option for stack based navigation platforms.Questions
How do we handle platforms that don't have a concept of a modal stack?
If we implement passing parameters does it make sense for all platforms?
Do we allow consumers to implement their own
IRoutingStackand register it for use with ReactiveUI?Are there any performance concerns or improvements that could come from this change?