3 ms·
I am interested in understanding this further -- is there a write-up or explanation with example anywhere regarding how you achieve this in Blazor.
by grok22 6y ago
I am interested in understanding this further -- is there a write-up or explanation with example anywhere regarding how you achieve this in Blazor.
- bob1029 6y agoAs far as I am aware, there is no public document on the internet which describes this approach in a consolidated way. Unfortunately, I cannot share examples from the codebase I am currently operating on. That said, I can offer some MS documentation links in hopes that this paints a slightly better picture for how I achieve this outcome. This describes how you would request a scoped stateful service from an arbitrary Razor Component: https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-3.1#request-a-service-in-a-component https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamen... This describes how you would inject these stateful services into DI in a way that scopes them as desired: https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/dependency-injection?view=aspnetcore-3.1#service-lifetime https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamen... Note that we are using Server-Side Blazor, so this approach works for us. I do not think it works with WASM (at least out of the box), but we do not care for this form of Blazor hosting right now, so its not a concern for us.
- Scarbutt 6y agoNote that we are using Server-Side Blazor, so this approach works for us. I do not think it works with WASM (at least out of the box), but we do not care for this form of Blazor hosting right now, so its not a concern for us. Hmm interesting, how does that work? What enables the interactivity in the browser?
- kovacs_ 6y agoBlazor Server downloads a small js script (SignalR) to the client on connection. All user events are sent back to the server through SignalR, then DOM changes are sent back to the client based off of user input. I use it at work for internal intranet web apps so it's pretty handy for our use case.