-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP feat(examples): add p/moul/pageable #3414
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is still in draft, but I took a look over the code and it is looking really nice. I put in a couple of notes and pointed out one place that you could avoid type conversions with a fun math trick. Let me know when its out of draft. I like this structure a lot.
// | ||
// // Generate pagination UI | ||
// ui := page.Picker() | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this breakdown in functionality, very clear to the reader.
// | ||
// This approach allows the interface to remain simple while supporting | ||
// bidirectional iteration through the implementation layer. | ||
IterateByOffset(offset int, count int, cb func(index interface{}, value interface{}) bool) bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a preference for interface{}
vs any
? It feels like any
is a nice shorthand in general.
totalItems := p.Source.Size() | ||
totalPages := 0 | ||
if pageSize > 0 { | ||
totalPages = int(math.Ceil(float64(totalItems) / float64(pageSize))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be more simply implemented as
totalPages = (totalItems + pageSize - 1) / pageSize
This avoids the need for type conversions.
p/moul/pageable
p/demo/avl/pager
p/moul/ulist/pager
Depends on #3407