Right now my child component only updates once the GetLeads() method in the parent component is finished. I never see the spinner or Searching text.
Parent Component:
<SearchResultComponent @ref="ChildComponent"></SearchResultComponent> Code:
protected SearchResultComponent ChildComponent; public int LeadsFound { get; set; } public void GetLeads() { ChildComponent.Refresh(true, 0); var leads = _searchService.Search(searchRequest); LeadsFound = leads?.Count ?? 0; _writeFileService.WriteToFile(leads); ChildComponent.Refresh(false, LeadsFound); } Child Component:
@code { public bool Searching { get; set; } = false; public int LeadsFound { get; set; } = 0; public void Refresh(bool searching, int leadsFound) { Searching = searching; LeadsFound = leadsFound; StateHasChanged(); } } @if (Searching) { <div>Searching...</div> <div> <img src="~/Content/searching-spinner.gif" /> </div> } else { <div>Leads Found: @LeadsFound</div> }
_searchService.Search(searchRequest)async? Same forWriteToFile()