Documentation
¶
Index ¶
- type Pager
- func (p *Pager[T]) Around(i int) (items []T, at, end int)
- func (p *Pager[T]) At(i int) *T
- func (p *Pager[T]) Error() error
- func (p *Pager[T]) FailedAt(i int) bool
- func (p *Pager[T]) IndexOf(fn func(*T) bool) int
- func (p *Pager[T]) Land(pg int, items []T, total int)
- func (p *Pager[T]) Len() int
- func (p *Pager[T]) PageCount() int
- func (p *Pager[T]) PageSize() int
- func (p *Pager[T]) Peek(i int) *T
- func (p *Pager[T]) Reload()
- func (p *Pager[T]) RemoveAt(i int)
- func (p *Pager[T]) Retry()
- func (p *Pager[T]) SetFirst(fn func(bool))
- func (p *Pager[T]) SetLanded(fn func(from int, items []T))
- func (p *Pager[T]) SetScope(ctx context.Context)
- func (p *Pager[T]) Total() int
- func (p *Pager[T]) When(pg int, fn func(bool))
- func (p *Pager[T]) Whole(fn func(bool))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pager ¶
type Pager[T any] struct { // contains filtered or unexported fields }
Pager keeps a long list sparse and loads the requested page plus a small read-ahead window. fetch receives one-based page numbers; all other methods use zero-based item/page indexes.
func New ¶
func New[T any](size, ahead int, post func(func()), fetch func(page int) ([]T, int, error)) *Pager[T]
New constructs a pager. post is called by worker completions on the owner goroutine; tests may pass a synchronous function.
func NewScoped ¶
func NewScoped[T any](ctx context.Context, size, ahead int, post func(func()), fetch func(context.Context, int) ([]T, int, error)) *Pager[T]
NewScoped binds page requests to the plugin activation that starts them.
func (*Pager[T]) Around ¶
Around returns the contiguous loaded run containing i, the item's offset, and the end index of the run.
func (*Pager[T]) IndexOf ¶
IndexOf finds the first loaded item matching fn without starting requests.
func (*Pager[T]) Land ¶
Land applies a page result. It is exported for deterministic adapters and tests that already have a response.
func (*Pager[T]) PageCount ¶
PageCount returns the number of physical pages once the total is known.
func (*Pager[T]) Reload ¶
func (p *Pager[T]) Reload()
Reload invalidates every page while keeping the known total and list geometry. This lets a sort or filter change show stable rows and skeletons instead of collapsing the whole page back to an unknown loading state.
func (*Pager[T]) Retry ¶
func (p *Pager[T]) Retry()
Retry makes failed pages eligible for loading again.
func (*Pager[T]) SetScope ¶
SetScope keeps loaded pages and detaches outstanding demand from the previous activation. Call it on the pager's owner goroutine.