I have implemented lazy loading for Blazor WebAssembly as per the code below.
When all required web assemblies have been loaded, I would like to load the rest of the web assemblies that have not yet been loaded.
Is there some built-in support for this?
If no, is there any event I can use to implement this on my own?
@inject ILogger<App> Logger@inject LazyAssemblyLoader AssemblyLoader<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="LazyLoadedAssemblies" OnNavigateAsync="HandleNavigateAsync"><Found Context="routeData"><RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /><FocusOnNavigate RouteData="@routeData" Selector="h1" /></Found><NotFound><PageTitle>Not found</PageTitle><LayoutView Layout="@typeof(MainLayout)"><p role="alert">Sorry, there's nothing at this address.</p></LayoutView></NotFound></Router>@code { public List<Assembly> LazyLoadedAssemblies { get; set; } = []; private async Task HandleNavigateAsync(NavigationContext args) { try { switch (args.Path) { case "Customer": { List<string> assemblyNamesForThisPath = ["BlazorWebAssemblyStandalone.Customer.wasm"]; var assemblies = await AssemblyLoader.LoadAssembliesAsync(assemblyNamesForThisPath); LazyLoadedAssemblies.AddRange(assemblies); break; } } } catch (Exception ex) { Logger.LogError("Error: {Message}", ex.Message); } }}