Closed ronaldtse closed 6 years ago
@ronaldtse do we really need HitPages
? It's possible to implement Array
's methods for HitCollection
. We can lazy load pages automatically when an index is out of a current page. So we don't have to manipulate pages by hand.
@andrew2net yes it's possible to use HitCollection
indeed -- my concern was what is the best way to communicate to users when lazy load will happen, and also how to make it not happen (as you imagine it is important to server-side code).
We can have a LazyCollection
that automatically calls hit.fetch
on access too. Thoughts?
P.S. I agree with you that HitPages
is not something the user needs to access, it might be useful internally, though.
implemented HitCollection
and HitPage
Implement a class
HitCollection < Array
(which already includes Enumerable) so that we not only have theeach
method but also the rest, likelength
?An array of
HitPage
s should be the result returned byScrapper
.This allows something like:
Accessing the second page of search results: