From e2a02f388709d7bbadf511bff63a38a91c9fa2aa Mon Sep 17 00:00:00 2001 From: Vladimir Seldemirov Date: Mon, 22 Apr 2024 12:10:48 +0400 Subject: [PATCH] Move StateHasChanged to PageViewModel --- src/BitzArt.Blazor.MVVM/Components/PageBase.cs | 2 -- .../ViewModels/PageViewModel.cs | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/BitzArt.Blazor.MVVM/Components/PageBase.cs b/src/BitzArt.Blazor.MVVM/Components/PageBase.cs index 475c1bc..a3b0777 100644 --- a/src/BitzArt.Blazor.MVVM/Components/PageBase.cs +++ b/src/BitzArt.Blazor.MVVM/Components/PageBase.cs @@ -21,8 +21,6 @@ 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 diff --git a/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs b/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs index 37a3b2d..f5956fb 100644 --- a/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs +++ b/src/BitzArt.Blazor.MVVM/ViewModels/PageViewModel.cs @@ -17,7 +17,15 @@ public virtual Task InitializeAsync() return Task.CompletedTask; } - internal abstract Task PersistStateAsync(); + internal virtual Task PersistStateAsync() => Task.CompletedTask; + + /// + /// Notifies the component that the state has changed. + /// + protected void StateHasChanged() + { + Component.StateHasChanged(); + } } /// @@ -81,12 +89,4 @@ internal override Task PersistStateAsync() return Task.CompletedTask; } - - /// - /// Notifies the component that the state has changed. - /// - protected void StateHasChanged() - { - Component.StateHasChanged(); - } }