func NewPager
NewPager creates a new Pager with default values
Package pageable implements a flexible pagination system that can be used with any data structure that implements the...
gno.land/p/moul/pageable/v0TODO: describe this package.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
Dependency graph:

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.
Package pageable implements a flexible pagination system that can be used with any data structure that implements the Pageable interface. It provides functionality for:
This package is currently used by:
Item represents a generic item in the page
Page represents a single page of results
Picker generates the Markdown UI for the page picker using default query string format
PickerWithPath generates the Markdown UI for the page picker with optional path If path is provided, it preserves existing query parameters (except page)
1type Pageable interface {
2 // Size returns the total number of items
3 Size() int
4
5 // IterateByOffset performs iteration starting from offset for count elements.
6 // The callback receives an index and a value, returns true to stop iteration.
7 //
8 // For reverse iteration, the implementation should handle the direction internally
9 // by adjusting how it interprets the offset and count parameters. For example:
10 // - In forward mode: offset 0, count 5 would return items [0,1,2,3,4]
11 // - In reverse mode: offset 0, count -5 would return items [4,3,2,1,0]
12 //
13 // This approach allows the interface to remain simple while supporting
14 // bidirectional iteration through the implementation layer.
15 IterateByOffset(offset int, count int, cb func(index interface{}, value interface{}) bool) bool
16}Pageable defines the minimal interface required for pagination. This interface is intentionally lightweight, requiring only two methods. While some data structures (like AVL trees) might have separate methods for forward and reverse iteration, this interface consolidates both directions into a single IterateByOffset method. It's the responsibility of the implementing wrapper to handle the direction logic internally based on the offset and count parameters.
Pager provides pagination functionality for any Pageable source
GetPage retrieves a page of results from the AVL tree.
GetPageByPath retrieves a page of results based on the query parameters in the URL path.