# Paginator

`class` in `http` · v0.2.3

<https://docs.seedcord.org/packages/http/0.2.3/classes/paginator>

A restart-proof paginator. Each nav button's customId encodes its full target page, so clicks are idempotent and survive a restart. A persistent `@ButtonRoute` on `Handler` dispatches the clicks.

```ts
class Paginator<Item, Prefix extends string> extends PaginatorBase<
    Item,
    Prefix,
    PageContext
>
```

## Examples

```ts
export const Bans = new Paginator({
    prefix: 'bans',
    source: new ArraySource((ctx) => loadBans(ctx.guildId), { perPage: 10 }),
    renderItem: (ban) => ban.user.username
});

\@ButtonRoute(Bans.cursor)
export class BansNav extends Bans.Handler {}
```

## Constructors

### constructor

```ts
Paginator(config: PaginatorConfig<Item, Prefix, PageContext>)
```

Constructs a new instance of the `Paginator` class

## Properties

### Handler

```ts
public readonly Handler: PaginatorHandlerCtor<Prefix>
```

The nav handler base. Extend it with an empty body and decorate it, `@ButtonRoute(p.cursor)`.

## Methods

### start

```ts
public async start(
    handler: RepliableHandler<Repliables>
): Promise<SentMessage>
```

Render page 0 and send it through the handler's sender, which picks reply, edit, or followUp from its ack state.
