Skip to content

Allow registering custom services before calling InitializeReactiveUI by adding HasRegistration check #2537

Open
@HrlecMatej

Description

@HrlecMatej

new Registrations().Register((f, t) => resolver.RegisterConstant(f(), t));
new PlatformRegistrations().Register((f, t) => resolver.RegisterConstant(f(), t));

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions