<EDIT>
Kind folks on the Clojurians Slack helped me understand how to use iteration
. Turns out it works absolutely fine. Slack thread is here.
The problem was my understanding of :somef
. I was using it like in this Juxt blog post (which is also incorrect) to signal iteration
that there are more pages to fetch. :somef
, instead, means "does the page we fetched contain any data?".
:kf
is what should be used to stop iteration or letting it continue:
If (kf ret) is non-nil it will be passed to the next step call, else iteration will terminate.
The test below can be fixed by removing :somef
altogether as in:
(into [] cat (iteration api :initk 0 :kf :tok :vf :ret))
Calling :tok
on the last page returns nil
, because the map doesn't contain :tok
at all. In that case iteration
stops.
</EDIT>
iteration
doesn't return the last "page" of data. This seems to be by design,
the docs say:
Iff (somef ret) is true, (vf ret) will be included in the iteration, else iteration will terminate and vf/kf will not be called.
The test below is missing items number 6 and 7. The API returns them in the last page,
setting :more
to false (meaning that pagination ended and there's no more data to fetch).