-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ResultingDelegate not working with custom widget when using multiple indices #43
Comments
Hey @aleincerto, Thanks for contacting us. I investigated the above and this is definitely a valid point you're making. What you're trying to do is currently not documented, and we'll make sure to add this soon. So to answer your question: The In order to do make it work with custom widgets, you need your custom widget to implement the protocol Also note that as soon as you're using multi-indexing with InstantSearch, then your custom widget will have to implement Thanks again for reporting this and let us know if you face any issue. |
Thanks a lot for the help! I might come back to you with some other questions later on. This InstantSearch framework is really good, nice stuff that you have going on in here. Keep it up. |
Thank you for the nice comment! Make sure to contact us if you face any other issues, we're always looking for feedback and ways to improve the library. |
Hello,
I have MKMapView extending the ResultingDelegate and implementing the on(results: SearchResults?, error: Error?, userInfo: [String: Any]) method, very similar to https://github.com/algolia/instantsearch-ios-examples/blob/master/Icebnb/Icebnb/MapViewWidget.swift.
I had been using a single index and this seemed to work fine, the on() method would get called after each Algolia search. However, I recently started using multiple indices and now the on() method of my MKMapView is not being called anymore. Looking at the code in InstantSearch.swift it seems like when calling InstantSearch.shared.registerAllWidgets(in: self.view) my custom widget should get added to the ResultingDelegates and thus it should work. What am I missing?
As a workaround I did:
InstantSearch.shared.getSearcher(named: Indeces.MAIN_INDEX)?.addResultHandler(mapView.on(results:error:userInfo:))
InstantSearch.shared.getSearcher(named: Indeces.SORTED_BY_RATING)?.addResultHandler(mapView.on(results:error:userInfo:))
and that seemed to fix my issue. However, shouldn't this happen automatically when registering the widgets?
Thank you
The text was updated successfully, but these errors were encountered: