Build a Paginated Cursor

Iterator pattern

Challenge 3 of Make It PluggableIntermediate~55 minFree

Learn the Iterator pattern by building a lazy paginated cursor. You will write a custom iterator over a list, make it work in for-loops, walk a page-serving backend fetching pages only on demand, prove the laziness by counting fetches, and finish with a generator that paginates in a few lines of code.

5 steps

  1. 1A Custom Iterator
  2. 2Works Everywhere an Iterator Works
  3. 3Paging a Backend Lazily
  4. 4Proving the Cursor Is Lazy
  5. 5A Generator That Paginates
Start step 1