Skip to content
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

Methods with implicit pagination should accept an include function #296

Open
theckman opened this issue Feb 27, 2021 · 0 comments
Open

Methods with implicit pagination should accept an include function #296

theckman opened this issue Feb 27, 2021 · 0 comments
Milestone

Comments

@theckman
Copy link
Collaborator

theckman commented Feb 27, 2021

Related to #294 #295, in v2 we should investigate having the paginated methods accept a func(T) bool where, where T is the type of item being paginated and the bool is whether the item should be included. For example,

func ListUsersPaginated(ctx context.Context, include func(User) bool) ([]User, error) { 
    if include == nil {
        include = func(User) bool { return true }
    }

    var collection []User

    // ...

    for _, u := range users {
        if include(u) {
            collection = append(collection, u)
        }
    }

    return collection, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant