Relative Content

Tag Archive for swiftswiftuipaginationscrollview

SwiftUI: Pagination of posts in a ScrollView

In my SwiftUI project, I have a file called SearchViewModel where I have defined a function called fetchRandomPosts(). This function is responsible for randomly retrieving posts from Firestore. My problem lies in the way these posts load in the UI. Currently, all posts are displayed at once, which is not optimal for the app. My goal is to implement more efficient loading, starting the initial load at just 18 posts. Then as the user scrolls down the screen, 6 additional posts would load and so on.