I have a need to adjust a child component based on the result of EventCallback<T>
async call, starting with reporting an error in validation summary. Yet I cannot seem to find a blazor-way to do this efficiently, it seems that communication is strictly one-way, from child to parent.
I read some SO answer that you can use Func<T1, T2>
instead of EventCallback<T>
, but that it has a serious downside of not calling StateHasChanged()
when needed.
[Parameter]
public EventCallback<int> OnAccountEntered { get; set; }
private async Task HandleValidSubmit()
{
try
{
DisableButton = true;
ButtonText = "Please Wait, Validating Account Information";
await OnAccountEntered.InvokeAsync(Model.AccountNumber ?? 0).ConfigureAwait(false);
// here be dragons. how do I get the answer from parent?
}
finally
{
ButtonText = "Request";
DisableButton = false;
}
}
What would be the proper way to assure this two-way communication between parent and child object?