Open Closed

Observable Collection and INotifyPropertyChanged in Blazor #6612


User avatar
0
cellero created
  • ABP Framework version: v8.0++
  • UI type: Blazor
  • DB provider: EF Core

I want to refresh data on a Blazor page when data in the collection changes. Do you have any advice / recommendations?

Currently I use a timer but periodically get the exception below - it occurs when one of the clients disconnects.

System.ObjectDisposedException HResult=0x80131622 Message=Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.

I'm considering implementing an INotifyCollectionChanged / Observable Collection: https://blazor.syncfusion.com/documentation/common/data-binding/data-updates But I'm not sure of the correct approach.

Any advice would be appreciated.


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi

    Yes, it's recommended.

    ABP also used INotifyCollectionChanged https://github.com/abpframework/abp/blob/e6e91bf11cd219ccab72633b13994dc5be2d2932/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs

  • User Avatar
    0
    cellero created

    Thanks, but the updates to the collection can be from any client.
    I want to set the NotificationChange at the repository level so that a change from 1 client triggers updates to all clients.

    Can, for example, the NotificationChange be implemented in the Domain Manager and for that to trigger Observable Collection updates?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    No, it's not possible. Blazor and the backend are independent processes.

    You can consider using SignalR.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11