[Blazor] Lazy loading - Complete example - Prevent repeated loads (#34243)
parent
a5766e2355
commit
9092b764ec
|
@ -592,16 +592,18 @@ The assembly is assigned to <xref:Microsoft.AspNetCore.Components.Routing.Router
|
|||
|
||||
@code {
|
||||
private List<Assembly> lazyLoadedAssemblies = new();
|
||||
private bool grantImaharaRobotControlsAssemblyLoaded;
|
||||
|
||||
private async Task OnNavigateAsync(NavigationContext args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (args.Path == "robot")
|
||||
if ((args.Path == "robot") && !grantImaharaRobotControlsAssemblyLoaded)
|
||||
{
|
||||
var assemblies = await AssemblyLoader.LoadAssembliesAsync(
|
||||
new[] { "GrantImaharaRobotControls.{FILE EXTENSION}" });
|
||||
lazyLoadedAssemblies.AddRange(assemblies);
|
||||
grantImaharaRobotControlsAssemblyLoaded = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -644,16 +646,18 @@ The assembly is assigned to <xref:Microsoft.AspNetCore.Components.Routing.Router
|
|||
|
||||
@code {
|
||||
private List<Assembly> lazyLoadedAssemblies = new List<Assembly>();
|
||||
private bool grantImaharaRobotControlsAssemblyLoaded;
|
||||
|
||||
private async Task OnNavigateAsync(NavigationContext args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (args.Path == "robot")
|
||||
if ((args.Path == "robot") && !grantImaharaRobotControlsAssemblyLoaded)
|
||||
{
|
||||
var assemblies = await AssemblyLoader.LoadAssembliesAsync(
|
||||
new[] { "GrantImaharaRobotControls.{FILE EXTENSION}" });
|
||||
lazyLoadedAssemblies.AddRange(assemblies);
|
||||
grantImaharaRobotControlsAssemblyLoaded = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
Loading…
Reference in New Issue