@@ -45,6 +45,7 @@ Instead, it re-exports from a core set of Seam modules:
4545 - [ Action Attempts] ( #action-attempts )
4646 - [ Pagination] ( #pagination )
4747 - [ Manually fetch pages with the nextPageCursor] ( #manually-fetch-pages-with-the-nextpagecursor )
48+ - [ Resume pagination] ( #resume-pagination )
4849 - [ Iterate over all pages] ( #iterate-over-all-pages )
4950 - [ Iterate over all resources] ( #iterate-over-all-resources )
5051 - [ Return all resources across all pages as an array] ( #return-all-resources-across-all-pages-as-an-array )
@@ -339,6 +340,32 @@ if (hasNextPage) {
339340}
340341```
341342
343+ #### Resume pagination
344+
345+ Get the first page on initial load:
346+
347+ ``` ts
348+ const params = { limit: 20 }
349+
350+ const pages = seam .createPaginator (seam .devices .list (params ))
351+
352+ const [devices, pagination] = await pages .firstPage ()
353+
354+ localStorage .setItem (' /seam/devices/list' , JSON .stringify ([params , pagination ]))
355+ ```
356+
357+ Get the next page at a later time:
358+
359+ ``` ts
360+ const [params = {}, { hasNextPage = false , nextPageCursor = null } = {}] =
361+ JSON .parse (localStorage .getItem (' /seam/devices/list' ) ?? ' []' )
362+
363+ if (hasNextPage ) {
364+ const pages = seam .createPaginator (seam .devices .list (params ))
365+ const [moreDevices] = await pages .nextPage (nextPageCursor )
366+ }
367+ ```
368+
342369#### Iterate over all pages
343370
344371``` ts
@@ -376,7 +403,7 @@ const pages = seam.createPaginator(
376403 }),
377404)
378405
379- const devices = await pages .toArray ()
406+ const devices = await pages .flattenToArray ()
380407```
381408
382409### Interacting with Multiple Workspaces
0 commit comments