This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-09
Channels
- # aws (3)
- # babashka (48)
- # babashka-sci-dev (1)
- # beginners (143)
- # calva (62)
- # clj-kondo (6)
- # clj-otel (3)
- # cljs-dev (59)
- # cljsrn (4)
- # clojure (39)
- # clojure-austin (5)
- # clojure-europe (60)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-romania (4)
- # clojure-spec (3)
- # clojure-uk (2)
- # clojurescript (32)
- # datomic (17)
- # events (3)
- # figwheel-main (4)
- # graphql (3)
- # gratitude (2)
- # holy-lambda (52)
- # introduce-yourself (3)
- # jobs (1)
- # juxt (5)
- # kaocha (2)
- # lsp (33)
- # nyc (3)
- # off-topic (9)
- # other-languages (4)
- # overtone (1)
- # portal (21)
- # reitit (2)
- # remote-jobs (5)
- # shadow-cljs (65)
- # tools-deps (2)
- # xtdb (8)
One can log to the console in two ways:
1. (js/console.log "blah")
2. (.log js/console "blah")
Which one would be the most preferred/idiomatic and why?
Which works well only for scalars. :)
As soon as it's an object of any kind, js/console.log
is much better, especially if you have cljs-devtools
installed.
for those of us using Firefox:
(defn log [& args] (apply js/console.log (clj->js args)) (first args))
Hopefully, that'll become obsolete soon: https://www.clojuriststogether.org/news/funding-development-on-custom-formatters-for-firefox/
But also, even without that, using stuff like Portal would probably be better than clj->js
.
Ah that's excellent they are funding that! Thanks for the heads-up about Portal.
I'm using p/let
from promesa
and generally having a lot of success. But I'm finding it tricky to avoid promise complaints when I call functions inside the p/let
that also have p/let
inside. For example when I want to fetch
data and then map over it with bunch of fetch
es per item. Is there an established pattern for this?
payments (fetch-pending-payments api options)
with-linked (map (fn [payment]
(let [data (account-data api (get-in payment [:details :sourceAccountId]))]
(merge payment data)))
payments)]
(p/let [url (js/URL. (str api-url "something"))
params (js/URLSearchParams. (clj->js search-conditions))
_ (j/assoc! url :search params)]
(p/-> (fetch url))
(.json)
(.-content)
(js->clj :keywordize-keys true)))
there is some small variations on let
bindings and the p/->
pipelines between the functions but it's the same pattern ...
the payments
binding resolves but the with-linked
comes back with a list of Promise
objects
sorry i mis-hit enter
if you are returning a seq of promises you probably want to use p/all
to wait for all of them.
hi guys, I created the channel #remix for having discussions about integrating clojurescript with remix.run
Is ^js
ever necessary with this-as
?
I.e. in code like this:
(this-as this
(.doStuff ^js this))
This feels like a Javascript joke, waiting for the punchline. I know it's not, and still feels like it 😊
Am I the only one who thought it was a Bill Clinton callback? :thinking_face: