Created
August 7, 2013 14:54
-
-
Save aamedina/6174766 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn page! | |
| [init-res req page-size] | |
| (reduce | |
| (fn [coll n] | |
| (let [req (update-in | |
| req [:query-params] | |
| merge | |
| {:max_id (:id_str (first coll))}) | |
| res (<!! (async-request req)) | |
| new-coll (into coll res)] | |
| (if (= (count new-coll) (count coll)) | |
| (reduced coll) | |
| new-coll))) | |
| (into (sorted-set-by #(compare (:id %1) (:id %2))) init-res) | |
| (range 50))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment