performance: Remove activator
glennawatson opened this issue · 1 comments
glennawatson commented
Consider removing the activator here
One way to remove it would be to do something like
public static void RegisterNavigation<TView, TViewModel>(IScheduler mainThreadScheduler = null, IScheduler backgroundScheduler = null, IViewLocator viewLocator = null)
where TView : new, IPageView, IViewFor
where TViewModel : class, IPageViewModel
{
var bgScheduler = mainThreadScheduler ?? RxApp.TaskpoolScheduler;
var mScheduler = backgroundScheduler ?? RxApp.MainThreadScheduler;
var vLocator = viewLocator ?? Locator.Current.GetService<IViewLocator>();
Locator.CurrentMutable.Register(
() => new TView { Scheduler = mScheduler, BackgroundScheduler = bgScheduler, ViewLocator = vLocator },
typeof(IViewFor<TViewModel>),
"NavigationView");
}
RLittlesII commented
I had a couple of thoughts:
- Have the user explicitly pass an instance
- Resolve them from the
Locator
which would force registration on the user - Take away the methods and bolster documentation on how to properly set this up yourself
- Provide an Initialize method similar to
InitializeReactiveUI()
so that all the Sextant bits get loadedSextant.Initialize();
. - Apply extension mixins for View/ViewModel registration from the
IMutableDependencyResolver
Specifically in the case of the NavigationView
this alleviates a lot of boiler plate setup when 90% of the time IView
is going to resolve to NavigationView
unless you've overridden it. In which case I'd assume you'd know you need to register your implementation in the Locator