diff --git a/README.md b/README.md index e56ced50..2acd3777 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,38 @@ 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') ?? '[]' +) + +const pages = seam.createPaginator( + seam.devices.list(params) +) + +if (hasNextPage) { + const [moreDevices] = await pages.nextPage(nextPageCursor) +} +``` + #### Iterate over all pages ```ts