-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
118 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.AspNetCore.Components.Routing; | ||
using System.Reflection; | ||
|
||
namespace RonSijm.Demo.Blazyload.Host; | ||
|
||
public partial class App | ||
{ | ||
private readonly List<Assembly> _lazyLoadedAssemblies = new(); | ||
|
||
private async Task OnNavigateAsync(NavigationContext args) | ||
{ | ||
try | ||
{ | ||
if (args.Path == "fetchdata1") | ||
{ | ||
var assemblies = await BlazyAssemblyLoader.LoadAssemblyAsync("RonSijm.Demo.Blazyload.WeatherLib1.wasm"); | ||
_lazyLoadedAssemblies.AddRange(assemblies); | ||
} | ||
else if (args.Path == "fetchdata2") | ||
{ | ||
var assemblies = await BlazyAssemblyLoader.LoadAssemblyAsync("RonSijm.Demo.Blazyload.WeatherLib2.wasm"); | ||
_lazyLoadedAssemblies.AddRange(assemblies); | ||
} | ||
else if (args.Path == "fetchdata3") | ||
{ | ||
var assemblies = await BlazyAssemblyLoader.LoadAssemblyAsync("RonSijm.Demo.Blazyload.WeatherLib3.wasm"); | ||
_lazyLoadedAssemblies.AddRange(assemblies); | ||
} | ||
else if (args.Path == "fetchdata4") | ||
{ | ||
var assemblies = await BlazyAssemblyLoader.LoadAssemblyAsync("RonSijm.Demo.Blazyload.WeatherLib4.Page.wasm"); | ||
_lazyLoadedAssemblies.AddRange(assemblies); | ||
} | ||
else if (args.Path == "fetchdataOptionalNull") | ||
{ | ||
var assemblies = await BlazyAssemblyLoader.LoadAssemblyAsync("RonSijm.Demo.Blazyload.WeatherLibOptionalNull.wasm"); | ||
_lazyLoadedAssemblies.AddRange(assemblies); | ||
} | ||
else if (args.Path == "fetchdataOptionalNotNull") | ||
{ | ||
var assemblies = await BlazyAssemblyLoader.LoadAssemblyAsync("RonSijm.Demo.Blazyload.WeatherLibOptionalNotNull.wasm"); | ||
_lazyLoadedAssemblies.AddRange(assemblies); | ||
} | ||
} | ||
catch (Exception) | ||
{ | ||
// Do Nothing | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Examples/RonSijm.Demo.Blazyload.WeatherLib3/Pages/FetchData.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace RonSijm.Demo.Blazyload.WeatherLib3.Pages; | ||
|
||
public partial class FetchData | ||
{ | ||
[Inject] | ||
public IWeatherResolver WeatherResolver { get; set; } | ||
|
||
private WeatherForecast[] _forecasts; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
_forecasts = await WeatherResolver.GetWeather(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/RonSijm.Blazyload/Features/DIComponents/IAssemblyLoader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace RonSijm.Blazyload.Features.DIComponents; | ||
|
||
public interface IAssemblyLoader | ||
{ | ||
event Action<List<Assembly>> OnAssembliesLoaded; | ||
Task<List<Assembly>> LoadAssemblyAsync(string assemblyToLoad); | ||
Task<List<Assembly>> LoadAssembliesAsync(IEnumerable<string> assembliesToLoad); | ||
} |