KallynGowdy / ReactiveUI.Routing

Experiments with routing in ReactiveUI
MIT License
11 stars 3 forks source link

SuspensionDriver Opt-in instead of Opt-out? #14

Open NZSmartie opened 6 years ago

NZSmartie commented 6 years ago

Picking up your library for https://github.com/NZSmartie/CoAPExplorer and got caught with weird navigation stacks The suspension driver was already started and navigated to malformed ViewModels. As my application is still proof of concept, there is no checking or UI to handle it.

I had to disable it (for now, will pick it up later) with

_reactiveApplication.SuspensionDriver.InvalidateState();

It may be an idea to add a feature flag to the extention methos (i.e. .ConfigureWpf()) to enable the default suspension driver.

Could you add a note to Readme saying that the SuspenstionDriver is configured when you build the ReactivApp and will store the navigation stack to disk.

KallynGowdy commented 6 years ago

Yeah, it's totally possible to do this right now actually. Basically, it requires calling IReactiveAppBuilder.Configure() with your own WpfConfiguration.

You would simply specify that the SuspensionConfiguration does not SetupPersistance. (SetupPersistance = false )

ConfigureWpf() is defined like this: https://github.com/KallynGowdy/ReactiveUI.Routing/blob/13755646ab6501148d33210f8e3ad958c70ca83a/src/ReactiveUI.Routing.WPF/ReactiveAppBuilderExtensions.cs#L16-L19

As you can see, it's really just calling Configure with a new WpfConfiguration object. You can change whether the suspension driver gets initialized by setting Suspension.SetupPersistance = false.

If you want to improve the ConfigureWpf() extension method to include this option by default, I'd be more than happy to accept a pull request. 😃