Search code examples
kotlinpaginationandroid-jetpack-composelazy-loading

Why do we use Pagination instead of Lazy {} to load data?


I 've watched a video on YouTube about creating Pokedex app in jetpack compose. And I wonder which is easier and suitable to load data.

Here is a link from that video: https://youtu.be/jrIfGAk8PyQ?si=kEeruW77QuWTqoDz

I'm a newbie and trying to understand the problem.Thanks!


Solution

  • the term pagination and lazy are not the same at all they serve different use cases.

    Pagination in simple terms is a way of fetching data from the API in chunks instead of loading all the data at once which can be ineffeicent and resource intensive especially with a large datasets for example gmail use this mechanism to load data with pagination, keep in mind to use pagination should be implemented in the API, it depends in the server side implementation some send 20 records other sends 50 and some are dynamic and you can implement how many records you would like to fetch, in the other hand the lazy column is just a way of how the data is rendering on the UI and how the data is represented in the screen in simple term its just renders the records that are visible on the screen.