Skip to content

Commit df3989e

Browse files
authored
docs: Document how to resume pagination (#293)
* Update fake-seam-connect * Update @seamapi/url-search-params-serializer * docs: Fix typo in README * docs: Document how to resume pagination
1 parent 37b9c1a commit df3989e

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

README.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,32 @@ if (hasNextPage) {
329329
}
330330
```
331331

332+
#### Resume pagination
333+
334+
Get the first page on initial load:
335+
336+
```ts
337+
const params = { limit: 20 }
338+
339+
const pages = seam.createPaginator(seam.devices.list(params))
340+
341+
const [devices, pagination] = await pages.firstPage()
342+
343+
localStorage.setItem('/seam/devices/list', JSON.stringify([params, pagination]))
344+
```
345+
346+
Get the next page at a later time:
347+
348+
```ts
349+
const [params = {}, { hasNextPage = false, nextPageCursor = null } = {}] =
350+
JSON.parse(localStorage.getItem('/seam/devices/list') ?? '[]')
351+
352+
if (hasNextPage) {
353+
const pages = seam.createPaginator(seam.devices.list(params))
354+
const [moreDevices] = await pages.nextPage(nextPageCursor)
355+
}
356+
```
357+
332358
#### Iterate over all pages
333359

334360
```ts
@@ -366,7 +392,7 @@ const pages = seam.createPaginator(
366392
}),
367393
)
368394

369-
const devices = await pages.toArray()
395+
const devices = await pages.flattenToArray()
370396
```
371397

372398
### Interacting with Multiple Workspaces

package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@
9292
}
9393
},
9494
"dependencies": {
95-
"@seamapi/url-search-params-serializer": "^1.1.0",
95+
"@seamapi/url-search-params-serializer": "^1.2.0",
9696
"axios": "^1.5.0",
9797
"axios-better-stacktrace": "^2.1.7",
9898
"axios-retry": "^4.4.2"
9999
},
100100
"devDependencies": {
101-
"@seamapi/fake-seam-connect": "^1.76.0",
101+
"@seamapi/fake-seam-connect": "^1.77.0",
102102
"@seamapi/types": "1.351.1",
103103
"@types/eslint": "^8.44.2",
104104
"@types/jsonwebtoken": "^9.0.6",

0 commit comments

Comments
 (0)