This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-21
Channels
- # announcements (10)
- # aws (38)
- # beginners (220)
- # calva (2)
- # cider (26)
- # clj-kondo (194)
- # cljs-dev (4)
- # clojure (190)
- # clojure-dev (7)
- # clojure-europe (3)
- # clojure-italy (6)
- # clojure-nl (4)
- # clojure-uk (8)
- # clojured (1)
- # clojurescript (29)
- # code-reviews (31)
- # community-development (9)
- # core-async (24)
- # cursive (38)
- # data-science (51)
- # datomic (52)
- # dirac (2)
- # emacs (3)
- # events (1)
- # figwheel-main (4)
- # fulcro (49)
- # graphql (13)
- # heroku (1)
- # hoplon (19)
- # immutant (3)
- # leiningen (1)
- # nrepl (59)
- # off-topic (12)
- # onyx (2)
- # pathom (51)
- # reitit (15)
- # shadow-cljs (88)
- # spacemacs (6)
- # sql (3)
- # tools-deps (107)
- # xtdb (11)
heya, a question please: What's the idiomatic CLJS way of interacting with promises? https://github.com/athos/kitchen-async offers something that looks pretty ok:
(require '[kitchen-async.promise :as p])
(p/let [browser (puppeteer/launch)
page (.newPage browser)]
(.goto page "")
(.screenshot page #js{:path "screenshot.png"})
(.close browser))
But I imagine there a similar way of doing this with core.async. I'm just having a lot of trouble finding a good example of it.I really like kitchen-async, and wouldn’t see an advantage of using core.async in its place
ok, that seems to be the overall sentiment for these cases
can you give me an example of how the code above would look like in the style you suggest please?
is it the same as the example in https://github.com/athos/kitchen-async#example?
(-> (js/fetch url)
(.then #(println %))
(.catch #(println %)))
but that’s for a chain of then
with cases like Puppeteer a chain of promises would look less readable, so something like p/let should be fine
ok, gotcha
and core.async doesn't really cover the single output case very well, I take it?
You can also write a thenP
and catchP
macro which take a promise as the first arg and wrap the rest of the args in an anonymous function body.
Instead of kitchen-async
also consider promesa
, it’s a bit better maintained (proper releases/changelog) IMHO — on the flipside it lacks some macro sugar that you may like or not like (e.g. promise aware threading macros)
yes I had tried promesa
already and was default to it, just wanted to know if I was missing something really obvious wrt core.async
I think the current community “thinking” wrt core.async is that it is very powerful and can do many amazing things but that 99% of the time you don’t need these amazing things and a more basic abstraction like promises are actually perfectly fine.
that description makes me feel a lot better, thank you 🙂
my pleasure 🙂
How might I get permissions to report a bug on the CLJS Jira? It tells me I don't have access after creating an account. I tracked down a bug where it hits an internal "not an absolute path" error about closure type external JS libs.
http://ask.clojure.org is the way to do this now
http://ask.clojure.org is the way to do this now
yes, please file a question at ask.clojure and tag it with problem
once triaged, a dev can file a jira
Thanks, I'll do that. https://clojurescript.org/community/reporting-issues should be updated to say this I think 🙂
yeah, I've updated all the clojure docs but haven't gotten to cljs. added to my list for today