This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-15
Channels
- # aleph (5)
- # announcements (1)
- # architecture (35)
- # babashka (9)
- # beginners (87)
- # chlorine-clover (13)
- # cider (3)
- # cljdoc (12)
- # clojure (16)
- # clojure-australia (2)
- # clojure-dev (4)
- # clojure-europe (5)
- # clojuredesign-podcast (21)
- # clojurescript (19)
- # conjure (1)
- # core-async (1)
- # data-science (1)
- # emacs (44)
- # events (2)
- # helix (1)
- # leiningen (2)
- # malli (31)
- # pathom (3)
- # pedestal (31)
- # portal (3)
- # reagent (20)
- # reitit (5)
- # reveal (2)
- # rewrite-clj (18)
- # tools-deps (6)
- # xtdb (5)
Thanks a lot to everybody who advised me on improving my function to fetch blog posts from a paginated API. I have applied your idea to use a dedicated stop-signal
instead of just closing the output dst
channel, which simplified the code, and @hiredman’s excellent idea to factor out the looping by creating an async version of core iterate
(it took me a while to understand it fully and I ended up writing a less flexible but easier for me to understand version of it).
Here is the original async-fetch-all-posts
https://github.com/holyjak/clj_tumblr_summarizer/blob/c1ca0ea37d2a6749466059bbf957647f5f989004/src/clj_tumblr_summarizer/input.clj#L49 combining async/thread, try, loop, let, when & if
and here is the refactored and renamed fetch-posts-async!
https://github.com/holyjak/clj_tumblr_summarizer/blob/e03395a0cd22ad52130e22d7b550561c35250f14/src/clj_tumblr_summarizer/input.clj#L67
(Here https://github.com/holyjak/clj_tumblr_summarizer/blob/e03395a0cd22ad52130e22d7b550561c35250f14/src/clj_tumblr_summarizer/input.clj#L50 I start the process producing pages of data and here is the factored-out async-iterate
https://github.com/holyjak/clj_tumblr_summarizer/blob/e03395a0cd22ad52130e22d7b550561c35250f14/src/clj_tumblr_summarizer/async_utils.clj#L20). If you have any comments, they would be of course most welcome.
It is more code now but simpler (not easier :)), I think.