-
Notifications
You must be signed in to change notification settings - Fork 9
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
infinum/feature/combine-pagination-refactor #64
base: master
Are you sure you want to change the base?
Conversation
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'd like @kvaljeva to take a look at this once he gets a chance before we do anything else 😄
/// Defines template for page | ||
protocol Page where Item: Pageable { | ||
|
||
/// Constraint results to types that conform to Pageable | ||
associatedtype Item | ||
|
||
var count: Int { get } | ||
var next: URL? { get } | ||
var previous: URL? { get } | ||
var pages: Int { get } | ||
var page: Int { get } | ||
var results: [Item] { get } | ||
} |
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.
Is there a reason why you went for an implementation where you would constrain it with where
instead of just making it generic? Then you wouldn't need the associatedType
if I'm not mistaken 😄
/// Defines template for page | |
protocol Page where Item: Pageable { | |
/// Constraint results to types that conform to Pageable | |
associatedtype Item | |
var count: Int { get } | |
var next: URL? { get } | |
var previous: URL? { get } | |
var pages: Int { get } | |
var page: Int { get } | |
var results: [Item] { get } | |
} | |
/// Defines template for page | |
protocol Page<Item: Pageable> { | |
var count: Int { get } | |
var next: URL? { get } | |
var previous: URL? { get } | |
var pages: Int { get } | |
var page: Int { get } | |
var results: [Item] { get } | |
} |
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 have tried it and it seams that protocols can't have generics in this sense, it wont compile, it has to be associatedType. Maybe I didn't understand your suggestion
func page( | ||
loadNextPage: AnyPublisher<Void, Never>, | ||
reload: AnyPublisher<Void, Never>, | ||
nextPage: @escaping PageableResultClosure, | ||
hasNextPage: @escaping HasNextPageClosure | ||
) -> AnyPublisher<[Pageable], PagingError> { |
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 feel like this should be something that is contained inside the interactor, what do you think @kvaljeva? Maybe we could do something more along the lines of the NetwokPaginationService we did?
Any status/update on this one? Its quite old, but let's decide if this will be improved and merged or closed. |
@nikolamajcen I have updated the code, just few answers from @ZvonimirMedak and @kvaljeva are needed to continue/finish. |
…ct...
Description
Please include a summary of the feature you have added.
Checklist:
public
modifier for all method and properties that could be changed from user of your feature, andprivate
for internal properties.