Skip to content

Commit

Permalink
Merge pull request #1499 from unoplatform/Youssef1313/docs-di
Browse files Browse the repository at this point in the history
docs(DI): Clarify DI docs
  • Loading branch information
nickrandolph authored Jun 2, 2023
2 parents 30a6689 + e0effdd commit 693e62f
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ Dependency Injection (DI) is an important design pattern for building loosely-co
}
}
```
* For the dependency injection framework to handle instantiation of the service as a constructor argument, you must also register your view model with the `IServiceCollection`:
* If you are using not using [navigation](xref:Overview.Navigation), you have to register the view model to `IServiceCollection`, but we recommend using navigation and not manually register the view model as a service:
```cs
private IHost Host { get; } = BuildAppHost();

private static IHost BuildAppHost()
{
return UnoHost
{
return UnoHost
.CreateDefaultBuilder()
.ConfigureServices(services =>
{
// Register your services
services.AddSingleton<IProfilePictureService, ProfilePictureService>();
{
// Register your services
services.AddSingleton<IProfilePictureService, ProfilePictureService>();
// Register view model
services.AddTransient<MainViewModel>();
})
})
.Build();
}
```
Expand Down

0 comments on commit 693e62f

Please sign in to comment.