Description
ReactiveUI/src/ReactiveUI/Mixins/DependencyResolverMixins.cs
Lines 42 to 43 in 4c03cbe
Allow registering custom services before calling InitializeReactiveUI by adding HasRegistration checks, similar to how InitializeSplat handles that
With this approach, one would register a custom service before the initialization call (like you currently do to override e.g. ILogger in InitializeSplat):
// (Autofac DI is used in the example)
// Register your overrides first
builder.RegisterType<MyCustomViewLocator>().As<IViewLocator>().SingleInstance();
// etc.
// Since I am using AutofacDependencyResolver, I call that at this point
var autofacResolver = builder.UseAutofacDependencyResolver();
// Register the resolver in Autofac so it can be later resolved
builder.RegisterInstance(autofacResolver);
// Then call InitializeReactiveUI, which would ignore already registered IViewLocator
autofacResolver.InitializeReactiveUI();
This means there aren't any redundant registrations, and no potential unexpected side-effects from that.