algolia / instantsearch-ios

⚡️ A library of widgets and helpers to build instant-search applications on iOS.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/ios/
Apache License 2.0
591 stars 55 forks source link

fix: SwiftUI infinite scrolling issue #228

Closed VladislavFitz closed 2 years ago

VladislavFitz commented 2 years ago

Summary

The existing implementation of HitsObservableController uses getCurrentHits function of HitsInteractor to build an observable list of hits. That's why the infinite scrolling didn't work correctly due optimization which keeps only 4 most recents pages of hits in memory. This PR adds hits computed property in HitsInteractor which ensures the correct hits pages to hits list by presenting the hits of unloaded pages as nil values.

Result

Inifinite scrolling works correctly with HitsObservableController.