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

breaking question down to possibly facilitate solution? #10

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/api/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,35 @@ export class Paginator<T extends Entity> {
};
}

/**
* Retrieves up to the next `pageSize` elements that satisfy the provided
* `filterCallback`. If a `startAfter` value is specified the elements
* starting _after_ `startAfter` are returned. Otherwise the 1st page is
* returned.
*
* Returns only array of items rather than Page data structure.
*/
private getItemsWithFilter(filterCallback: (item: T) => boolean, pageSize: number, startAfter?: T): T[] {
// PART TWO
// Implement filtering of relevant items from store.

return this.source.getItems(pageSize, startAfter); // TODO
}

/**
* Retrieves up to the next `pageSize` elements that satisfy the provided
* `filterCallback`. If a `startAfter` value is specified the elements
* starting _after_ `startAfter` are returned. Otherwise the 1st page is
* returned.
*/
getNextPageWithFilter(filterCallback: (item: T) => boolean, pageSize: number, startAfter?: T): Page<T> {
// PART TWO
// Implement routine to return filtered page.
// PART THREE
// Implement hasMoreResults for filtered pages.

return this.getNextPage(pageSize, startAfter);
return {
results: this.getItemsWithFilter(filterCallback, pageSize, startAfter),
hasMoreResults: false, // TODO
};
}
}

Expand Down