Skip to content

Commit

Permalink
feat(blazorui): remove singleton option from BlazorUI service registr…
Browse files Browse the repository at this point in the history
…ation #9379 (#9380)
  • Loading branch information
msynk authored Dec 2, 2024
1 parent f677c5c commit 90754c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
10 changes: 8 additions & 2 deletions src/BlazorUI/Bit.BlazorUI.Extras/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ namespace Bit.BlazorUI;

public static class IServiceCollectionExtensions
{
public static IServiceCollection AddBitBlazorUIExtrasServices(this IServiceCollection services, bool singleton = false)
/// <summary>
/// Registers required services of the Extras package of the BitBlazorUI components.
/// </summary>
/// <param name="services"></param>
/// <param name="trySingleton">Tries to register the services as singleton, but only for the services can be singleton (e.g. the services that do not use IJSRuntime).</param>
/// <returns></returns>
public static IServiceCollection AddBitBlazorUIExtrasServices(this IServiceCollection services, bool trySingleton = false)
{
if (singleton)
if (trySingleton)
{
services.TryAddSingleton<BitModalService>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ namespace Bit.BlazorUI;

public static class IServiceCollectionExtensions
{
public static IServiceCollection AddBitBlazorUIServices(this IServiceCollection services, bool singleton = false)
public static IServiceCollection AddBitBlazorUIServices(this IServiceCollection services)
{
if (singleton)
{
services.TryAddSingleton<BitThemeManager>();
}
else
{
services.TryAddScoped<BitThemeManager>();
}
services.TryAddScoped<BitThemeManager>();

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static IServiceCollection AddClientSharedServices(this IServiceCollection
services.TryAddTransient<LazyAssemblyLoader>();
services.TryAddScoped<NavManuService>();

services.AddBitBlazorUIServices(singleton: AppRenderMode.IsBlazorHybrid);
services.AddBitBlazorUIExtrasServices(singleton: AppRenderMode.IsBlazorHybrid);
services.AddBitBlazorUIServices();
services.AddBitBlazorUIExtrasServices(trySingleton: AppRenderMode.IsBlazorHybrid);
services.AddSharedServices();

return services;
Expand Down

0 comments on commit 90754c0

Please sign in to comment.