I have a backend .NET 6 Web API RESTful service solution that exposes a complex class which is consumed by a Blazor Server App. Whenever the backend Web API's instantiated class changes values, I need to transmit that changed class to the Blazor app. Currently the Blazor app makes all of the calls to the backend service as would be expected.
I have been attempting to get an EventCallback working to overcome this challenge but it does not work. All of the examples I have found, such as https://blazor-university.com/components/component-events/, include their example within the same Blazor app.
Can somebody please point me in the right direction?
Thank you!
CodePudding user response:
The EventCallback
is a struct specifically created to be used in Blazor. It's purpose is to determine the type of the delegate of your event handler.
What you really need is a real time Notification System. It is best implemented through SignalR. Start working on it, and let us know of your difficulties.
Here's a complete working code sample of SignalR used with Blazor Server App with authentication.
A simpler solution, however, is to create a service that implements a Timer object, to query the database at given intervals.