My application upload a list of components into our ERP. The upload process can take 1 or 2 minutes. I would like to notify in real time the user what is going on.
I created a blazor server app. I have the razor page with some UI logics but I didn't want to put all the processing logic inside the razor page. So I put it into a worker.
How the worker can push notification to the blazor component ?
I red about SignalR, but they are mostly about blazor webassembly or too basic for me to see how I can apply it to my situation.
I was wondering what is the good approach ?
You use the Notification pattern. The service - what you call a worker - raises an event whenever a change happens. Any UI components that need to know about the change register an event handler on the service event. Normally the event handler just calls StateHasChanged
.
Here's a Stackflow answer that demonstrates the Notification pattern using the WeatherForecast list. How can I trigger/refresh my main .RAZOR page from all of its sub-components within that main .RAZOR page when an API call is complete?