Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Instead, it re-exports from a core set of Seam modules:
- [Action Attempts](#action-attempts)
- [Pagination](#pagination)
- [Manually fetch pages with the nextPageCursor](#manually-fetch-pages-with-the-nextpagecursor)
- [Resume pagination](#resume-pagination)
- [Iterate over all pages](#iterate-over-all-pages)
- [Iterate over all resources](#iterate-over-all-resources)
- [Return all resources across all pages as an array](#return-all-resources-across-all-pages-as-an-array)
Expand Down Expand Up @@ -339,6 +340,32 @@ if (hasNextPage) {
}
```

#### Resume pagination

Get the first page on initial load:

```ts
const params = { limit: 20 }

const pages = seam.createPaginator(seam.devices.list(params))

const [devices, pagination] = await pages.firstPage()

localStorage.setItem('/seam/devices/list', JSON.stringify([params, pagination]))
```

Get the next page at a later time:

```ts
const [params = {}, { hasNextPage = false, nextPageCursor = null } = {}] =
JSON.parse(localStorage.getItem('/seam/devices/list') ?? '[]')

if (hasNextPage) {
const pages = seam.createPaginator(seam.devices.list(params))
const [moreDevices] = await pages.nextPage(nextPageCursor)
}
```

#### Iterate over all pages

```ts
Expand Down Expand Up @@ -376,7 +403,7 @@ const pages = seam.createPaginator(
}),
)

const devices = await pages.toArray()
const devices = await pages.flattenToArray()
```

### Interacting with Multiple Workspaces
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"npm": ">= 9.0.0"
},
"dependencies": {
"@seamapi/http": "1.25.0",
"@seamapi/http": "1.25.1",
"@seamapi/types": "1.356.0",
"@seamapi/webhook": "1.1.1",
"zod": "^3.21.4"
Expand Down