This page documents some useful features of Blazor and how to best use them from a Bolero application.
Blazor provides the ability to work with the dependency injection mechanism introduced by ASP.NET Core. Learn more about it on the official documentation.
Any Blazor component can require a dependency. This includes the Bolero
ProgramComponent, as well as any
Component class you create. This is done by creating a mutable property with the attribute
open Microsoft.AspNetCore.Components open Bolero type MyApp() = inherit ProgramComponent<Model, Message>() [<Inject>] member val MyDependency = Unchecked.defaultof<IMyDependency> with get, set override this.Program = doSomethingWith this.MyDependency
Dependencies are injected from the client-side
type Startup() = member __.ConfigureServices(services: IServiceCollection) = services.AddSingleton<IMyDependency>(new MyDependency()) |> ignore