diff --git a/src/BitzArt.Blazor.MVVM/Components/IPersistentComponent.cs b/src/BitzArt.Blazor.MVVM/Components/IPersistentComponent.cs index 0eea0df..1b86235 100644 --- a/src/BitzArt.Blazor.MVVM/Components/IPersistentComponent.cs +++ b/src/BitzArt.Blazor.MVVM/Components/IPersistentComponent.cs @@ -5,4 +5,6 @@ namespace BitzArt.Blazor.MVVM; internal interface IPersistentComponent : IComponent { internal PersistentComponentState ComponentState { get; } + + internal void StateHasChanged(); } diff --git a/src/BitzArt.Blazor.MVVM/Components/PageBase.cs b/src/BitzArt.Blazor.MVVM/Components/PageBase.cs index 4066105..475c1bc 100644 --- a/src/BitzArt.Blazor.MVVM/Components/PageBase.cs +++ b/src/BitzArt.Blazor.MVVM/Components/PageBase.cs @@ -21,6 +21,8 @@ public abstract class PageBase : ComponentBase, IPersistentComponent [Inject] protected TViewModel ViewModel { get; set; } = null!; + PersistentComponentState IPersistentComponent.ComponentState => throw new NotImplementedException(); + /// /// Method invoked when the component is ready to start, having received its initial /// parameters from its parent in the render tree. Override this method if you will @@ -40,4 +42,9 @@ private async Task PersistStateAsync() { await ViewModel.PersistStateAsync(); } + + void IPersistentComponent.StateHasChanged() + { + StateHasChanged(); + } } diff --git a/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs b/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs index a7e88e2..37a3b2d 100644 --- a/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs +++ b/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs @@ -81,4 +81,12 @@ internal override Task PersistStateAsync() return Task.CompletedTask; } + + /// + /// Notifies the component that the state has changed. + /// + protected void StateHasChanged() + { + Component.StateHasChanged(); + } }