The better solution is to invoke the method in the set value of the parameter.
@code {
string _myString;
[Parameter]
public string MyString
{
get {return _myString; }
set {
_myString = value;
this.ValueChange();
}
}
private void ValueChange()
{
Console.WriteLine("Parameter value has changed");
}
}
You can also override the OnParameterSet or OnParameterSetAsync lifecycle methods. Those methods are triggered every time any parameter value changes.
@code
{
[Parameter]
protected string MyString {get;set;}
protected override void OnParametersSet()
{
this.ValueChange();
}
private void ValueChange()
{
Console.WriteLine("Parameter value has changed");
}
}
Share with