@@ -45,6 +45,7 @@ Instead, it re-exports from a core set of Seam modules:
45
45
- [ Action Attempts] ( #action-attempts )
46
46
- [ Pagination] ( #pagination )
47
47
- [ Manually fetch pages with the nextPageCursor] ( #manually-fetch-pages-with-the-nextpagecursor )
48
+ - [ Resume pagination] ( #resume-pagination )
48
49
- [ Iterate over all pages] ( #iterate-over-all-pages )
49
50
- [ Iterate over all resources] ( #iterate-over-all-resources )
50
51
- [ Return all resources across all pages as an array] ( #return-all-resources-across-all-pages-as-an-array )
@@ -339,6 +340,32 @@ if (hasNextPage) {
339
340
}
340
341
```
341
342
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
+
342
369
#### Iterate over all pages
343
370
344
371
``` ts
@@ -376,7 +403,7 @@ const pages = seam.createPaginator(
376
403
}),
377
404
)
378
405
379
- const devices = await pages .toArray ()
406
+ const devices = await pages .flattenToArray ()
380
407
```
381
408
382
409
### Interacting with Multiple Workspaces
0 commit comments