Event "result" is not trigger on searchHelper #4924
-
Hello, I have a searchHelper function defined as following filterSearchResults.prototype.searchHelper = function searchHelper(helper) {
const that = this;
helper.setIndex(this.indexName);
helper.clearRefinements("category");
if (this.facetFilters.category.length > 0) {
helper.addFacetRefinement("category", this.facetFilters.category);
}
helper.clearRefinements("subcategories");
if (this.facetFilters.subcategories.length > 0) {
this.facetFilters.subcategories.forEach((subcategory) => {
helper.addDisjunctiveFacetRefinement("subcategories", subcategory);
});
}
helper.on("result", (results) => {
console.log("here");
that.checkAvailability(results);
});
helper.search();
}; The problem is that on('result') event is not triggered when the search is executed. However, I noticed that if I bind it to derived helper on('result') of mainHelper variable in InstantSearch.js the event is triggered just fine. Is this expected behavior? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
It looks like this isn't the complete implementation of your interface. In the context of InstantSearch relying directly on the helper interface for anything other than reading items of SearchResults and setting SearchParameters in getWidgetSearchParameters is not supported. A bit of background: the search actually happens on derived helpers only in InstantSearch, as this allowed us to implement multi-index with less changes. The search method on the helper instance is overridden to have that behaviour |
Beta Was this translation helpful? Give feedback.
It looks like this isn't the complete implementation of your interface. In the context of InstantSearch relying directly on the helper interface for anything other than reading items of SearchResults and setting SearchParameters in getWidgetSearchParameters is not supported.
A bit of background: the search actually happens on derived helpers only in InstantSearch, as this allowed us to implement multi-index with less changes. The search method on the helper instance is overridden to have that behaviour