Update UI state after search API request completes with no results
When a search API request returns results, the returned annotations are added to the app state and this transition triggers a digest cycle. When there are no results however, this was not happening and the value of the 'isLoading()' function changed but no digest cycle was triggered to pick this up and reflect it in the UI. Since SearchClient's 'end' event is emitted asynchronously via a Promise callback, $scope.$apply() or $evalAsync() must be used to ensure that change detection runs. The real solution will be to store all the information required to determine the loading/not-loading state in the Redux store, so that any transition automatically triggers a digest cycle. This requires some more extensive refactoring however.
Showing
Please register or sign in to comment