iqm.station_control.interface.pagination.paginate

Contents

iqm.station_control.interface.pagination.paginate#

paginate(fetch_page, *, limit=None)#

Lazily yield items from a limit/offset-paginated backend, fetching pages on demand.

The caller doesn’t have to think about pagination: not passing limit yields every matching item, fetched lazily one page at a time, exactly like passing limit=0.

Parameters:
  • fetch_page (Callable[[int, int], ListWithMeta[T]]) – Callable taking (limit, offset) for a single page and returning it.

  • limit (int | None) – Maximum number of items to yield in total. Not given (or 0, or a negative number) means unlimited: every matching item is yielded.

Return type:

Iterator[T]