Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Add OnStateChanged (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ligowsky authored May 7, 2024
1 parent de5fec3 commit 95cc86c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/BitzArt.Blazor.MVVM/Models/ComponentViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ public abstract class ComponentViewModel<TState> : ComponentViewModel, IStateful
public object ComponentState
{
get => State;
set => State = (TState)value;
set
{
State = (TState)value;
OnStateChanged(State);
}
}

/// <summary>
Expand All @@ -57,4 +61,9 @@ public virtual Task InitializeStateAsync()
{
return Task.CompletedTask;
}

/// <summary>
/// Called when the state has changed.
/// </summary>
protected virtual void OnStateChanged(TState state) { }
}

0 comments on commit 95cc86c

Please sign in to comment.